Merge "Correctly set job known/running attributes"

This commit is contained in:
Jenkins 2013-12-04 00:47:05 +00:00 committed by Gerrit Code Review
commit 9c110fb84e
2 changed files with 33 additions and 2 deletions

View File

@ -1436,8 +1436,8 @@ class Client(BaseClient):
"""
job = packet.getJob()
job.known = (packet.getArgument(1) == 1)
job.running = (packet.getArgument(2) == 1)
job.known = (packet.getArgument(1) == '1')
job.running = (packet.getArgument(2) == '1')
job.numerator = packet.getArgument(3)
job.denominator = packet.getArgument(4)

View File

@ -39,5 +39,36 @@ class ConnectionTestCase(tests.BaseTestCase):
'host: %s port: %s>' % (self.host, self.port)))
class TestClient(tests.BaseTestCase):
def test_handleStatusRes_1(self):
client = gear.Client()
packet = gear.Packet(
gear.constants.RES,
gear.constants.STATUS_RES,
b'H:127.0.0.1:11\x001\x001\x00\x00'
)
packet.getJob = lambda: gear.Job("", "")
job = client.handleStatusRes(packet)
self.assertTrue(job.known)
self.assertTrue(job.running)
def test_handleStatusRes_2(self):
client = gear.Client()
packet = gear.Packet(
gear.constants.RES,
gear.constants.STATUS_RES,
b'H:127.0.0.1:11\x001\x000\x00\x00'
)
packet.getJob = lambda: gear.Job("", "")
job = client.handleStatusRes(packet)
self.assertTrue(job.known)
self.assertFalse(job.running)
def load_tests(loader, in_tests, pattern):
return testscenarios.load_tests_apply_scenarios(loader, in_tests, pattern)