def test_receive_logs(): log_file_name = 'test_logging.log' lego = Lego(None, threading.Lock(), log_file_name) message = Message('Test Message 1', Metadata(None).__dict__, True).__dict__ lego.on_receive(message) with open(log_file_name, mode='r') as f: log = json.loads(f.read()) assert log == message # nosec os.remove(log_file_name)
def test_on_receive_informs_children(): log_file_name = 'test_child_informed.log' baseplate = Lego(None, threading.Lock()) child = Lego.start(baseplate, threading.Lock(), log_file_name) baseplate.children.append(child) message = Message('Test Message 1', Metadata(None).__dict__, True).__dict__ baseplate.on_receive(message) child.stop() with open(log_file_name, mode='r') as f: log = json.loads(f.read()) os.remove(log_file_name) assert log == message # nosec