def _test_loop(self): class ConnectionStub: exits = False def clean_up(self): self.exits = True connection_stub = ConnectionStub() properties = {DEVICE_GROUP : "test"} task_broker = TaskBroker(connection_stub, properties) #Case where no stop file and keep_looping_true class ChannelStub: wait_called = False def wait(self): self.wait_called = True task_broker._keep_looping = False channel_stub = ChannelStub() task_broker._connection.channel = channel_stub task_broker._loop() self.assertTrue(channel_stub.wait_called) #Case where keep_looping False task_broker._keep_looping = False task_broker._loop() self.assertTrue(connection_stub.exits) #Case where stop_file_exists connection_stub.exits = False task_broker._keep_looping = True def _stop_file_exists(): return True task_broker._stop_file_exists = _stop_file_exists task_broker._loop() self.assertTrue(connection_stub.exits)
def _test_loop(self): class ConnectionStub: exits = False def clean_up(self): self.exits = True connection_stub = ConnectionStub() properties = {DEVICE_GROUP: "test"} task_broker = TaskBroker(connection_stub, properties) #Case where no stop file and keep_looping_true class ChannelStub: wait_called = False def wait(self): self.wait_called = True task_broker._keep_looping = False channel_stub = ChannelStub() task_broker._connection.channel = channel_stub task_broker._loop() self.assertTrue(channel_stub.wait_called) #Case where keep_looping False task_broker._keep_looping = False task_broker._loop() self.assertTrue(connection_stub.exits) #Case where stop_file_exists connection_stub.exits = False task_broker._keep_looping = True def _stop_file_exists(): return True task_broker._stop_file_exists = _stop_file_exists task_broker._loop() self.assertTrue(connection_stub.exits)