Correctly set job known/running attributes

In Client.handleStatusRes the known and complete arguments in STATUS_RES
packets were being compared to integers, they should be compared to
strings.

Change-Id: I170ee12955263065a4adff4221e5bc60015cae70
This commit is contained in:
Derek Higgins 2013-11-28 16:41:54 +00:00
parent f74572696b
commit 3a8595635a
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)