def test_event(self): source_client_guid = UuidGenerator.generate_id_as_string() source_broker_guid = UuidGenerator.generate_id_as_string() source_broker_ids = ["{66000000-0000-0000-0000-000000000001}", "{66000000-0000-0000-0000-000000000002}", "{66000000-0000-0000-0000-000000000003}"] source_client_ids = ["{25000000-0000-0000-0000-000000000001}", "{25000000-0000-0000-0000-000000000002}", "{25000000-0000-0000-0000-000000000003}"] source_payload = "EVENT".encode() event = Event(destination_topic="") event._source_client_id = source_client_guid event._source_broker_id = source_broker_guid event.broker_ids = source_broker_ids event.client_ids = source_client_ids event.payload = source_payload PP.pprint(vars(event)) message = event._to_bytes() PP.pprint(message) result = Message._from_bytes(message) PP.pprint(vars(result)) self.assertEqual(source_client_guid, result.source_client_id) self.assertEqual(source_broker_guid, result.source_broker_id) self.assertEqual(source_broker_ids, result.broker_ids) self.assertEqual(source_client_ids, result.client_ids) self.assertEqual(source_payload, result.payload) self.assertEqual(Message.MESSAGE_TYPE_EVENT, result.message_type)
def test_event(self): source_client_guid = UuidGenerator.generate_id_as_string() source_broker_guid = UuidGenerator.generate_id_as_string() event = Event(destination_topic="") event._source_client_id = source_client_guid event._source_broker_id = source_broker_guid event.broker_ids = ["{66000000-0000-0000-0000-000000000001}", "{66000000-0000-0000-0000-000000000002}", "{66000000-0000-0000-0000-000000000003}"] event.client_ids = ["{25000000-0000-0000-0000-000000000001}", "{25000000-0000-0000-0000-000000000002}", "{25000000-0000-0000-0000-000000000003}"] event.payload = str.encode("EVENT") pp.pprint(vars(event)) message = event._to_bytes() pp.pprint(message) result = Message._from_bytes(message) pp.pprint(vars(result)) assert result.source_client_id == source_client_guid assert result.source_broker_id == source_broker_guid assert result.broker_ids == ["{66000000-0000-0000-0000-000000000001}", "{66000000-0000-0000-0000-000000000002}", "{66000000-0000-0000-0000-000000000003}"] assert result.client_ids == ["{25000000-0000-0000-0000-000000000001}", "{25000000-0000-0000-0000-000000000002}", "{25000000-0000-0000-0000-000000000003}"] assert result.payload == str.encode("EVENT") assert result.message_type == Message.MESSAGE_TYPE_EVENT