def test_event_container(): container = EventContainer('test', {}) container.set_owner('testowner') container.set_fingerprint('testfp') container.set_metadata({'a': 'b'}) record = container.get_record() assert record.owner == 'testowner' assert record.fingerprint == 'testfp' assert 'a' in record.event_metadata
def test_event_container(): container = EventContainer("test", {}) container.set_owner("testowner") container.set_fingerprint("testfp") container.set_metadata({"a": "b"}) record = container.get_record() assert record.owner == "testowner" assert record.fingerprint == "testfp" assert "a" in record.event_metadata
def messages() -> List[EventContainer]: """Get all test messages and their filenames as an iterator. Returns: EventContainer: some test event """ event = EventContainer("test", {}) event.set_owner("*****@*****.**") event.set_fingerprint("test") return [event]
def get_all_test_messages(parsed=False): """Get all test messages and their filenames as an iterator. Args: parsed (bool): returns Event objects if true otherwise strings Yields: EventContainer: some test event """ event = EventContainer("test", {}) event.set_owner("*****@*****.**") event.set_fingerprint("test") return [event]
def test_message_callback(app): @app.register_parser('test') def parse_message(message): ev = json.loads(message) if 'a' in ev: return ev, None raise ValueError('fail') hydrator_mock = mock.Mock() app.register_hydrator('test', hydrator_mock) filter_return_value = EventContainer('test', {"a": "b"}) filter_mock = mock.Mock(return_value=filter_return_value) app.register_filter('test', filter_mock) assert not app.message_callback('test1', '{}') assert not app.message_callback('test', '{ "c": "d" }') app.message_callback('test', '{ "a": "b" }') assert hydrator_mock.called assert filter_mock.called assert filter_mock.return_value, filter_return_value
def test_message_callback(app): @app.register_parser("test") def parse_message(message): ev = json.loads(message) if "a" in ev: return ev, None raise ValueError("fail") hydrator_mock = mock.Mock() app.register_hydrator("test", hydrator_mock) filter_return_value = EventContainer("test", {"a": "b"}) filter_mock = mock.Mock(return_value=filter_return_value) app.register_filter("test", filter_mock) assert not app.message_callback("test1", "{}") assert not app.message_callback("test", '{ "c": "d" }') app.message_callback("test", '{ "a": "b" }') assert hydrator_mock.called assert filter_mock.called assert filter_mock.return_value, filter_return_value