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:
parent
f74572696b
commit
3a8595635a
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user