class EventStorageTest(TestCase): def setUp(self): self.eventstorage = EventStorage() def test_minimal_columns(self): assert len(self.eventstorage.minimal_columns) == 4 def test_full_columns(self): assert len(self.eventstorage.full_columns) == 17 def test_bind_nodes(self): """ Test that bind_nodes populates _node_data """ min_ago = (timezone.now() - timedelta(minutes=1)).isoformat()[:19] self.store_event( data={"event_id": "a" * 32, "timestamp": min_ago, "user": {"id": u"user1"}}, project_id=self.project.id, ) self.store_event( data={"event_id": "b" * 32, "timestamp": min_ago, "user": {"id": u"user2"}}, project_id=self.project.id, ) event = eventstore.get_event_by_id(self.project.id, "a" * 32) event2 = eventstore.get_event_by_id(self.project.id, "b" * 32) assert event.data._node_data is None self.eventstorage.bind_nodes([event, event2], "data") assert event.data._node_data is not None assert event.data["user"]["id"] == u"user1"
class EventStorageTest(TestCase): def setUp(self): self.eventstorage = EventStorage() def test_minimal_columns(self): assert len(self.eventstorage.minimal_columns) == 4 def test_full_columns(self): assert len(self.eventstorage.full_columns) == 17 def test_bind_nodes(self): """ Test that bind_nodes populates _node_data """ min_ago = iso_format(before_now(minutes=1)) self.store_event( data={"event_id": "a" * 32, "timestamp": min_ago, "user": {"id": u"user1"}}, project_id=self.project.id, ) self.store_event( data={"event_id": "b" * 32, "timestamp": min_ago, "user": {"id": u"user2"}}, project_id=self.project.id, ) event = Event(project_id=self.project.id, event_id="a" * 32) event2 = Event(project_id=self.project.id, event_id="b" * 32) assert event.data._node_data is None self.eventstorage.bind_nodes([event, event2], "data") assert event.data._node_data is not None assert event.data["user"]["id"] == u"user1" # Bind nodes is noop if node data was already fetched with mock.patch.object(nodestore, "get_multi") as mock_get_multi: self.eventstorage.bind_nodes([event, event2]) assert mock_get_multi.call_count == 0
class EventStorageTest(TestCase): def setUp(self): self.eventstorage = EventStorage() def test_minimal_columns(self): assert len(self.eventstorage.minimal_columns) == 4 def test_bind_nodes(self): """ Test that bind_nodes populates _node_data """ min_ago = iso_format(before_now(minutes=1)) self.store_event( data={"event_id": "a" * 32, "timestamp": min_ago, "user": {"id": "user1"}}, project_id=self.project.id, ) self.store_event( data={"event_id": "b" * 32, "timestamp": min_ago, "user": {"id": "user2"}}, project_id=self.project.id, ) event = Event(project_id=self.project.id, event_id="a" * 32) event2 = Event(project_id=self.project.id, event_id="b" * 32) assert event.data._node_data is None self.eventstorage.bind_nodes([event, event2], "data") assert event.data._node_data is not None assert event.data["user"]["id"] == "user1"
class EventStorageTest(TestCase): def setUp(self): self.eventstorage = EventStorage() def test_minimal_columns(self): assert len(self.eventstorage.minimal_columns) == 4 def test_full_columns(self): assert len(self.eventstorage.full_columns) == 16 def test_bind_nodes(self): """ Test that bind_nodes populates _node_data """ min_ago = (timezone.now() - timedelta(minutes=1)).isoformat()[:19] self.store_event( data={ 'event_id': 'a' * 32, 'timestamp': min_ago, 'user': { 'id': u'user1', }, }, project_id=self.project.id, ) self.store_event( data={ 'event_id': 'b' * 32, 'timestamp': min_ago, 'user': { 'id': u'user2', }, }, project_id=self.project.id, ) event = eventstore.get_event_by_id(self.project.id, 'a' * 32) event2 = eventstore.get_event_by_id(self.project.id, 'b' * 32) assert event.data._node_data is None self.eventstorage.bind_nodes([event, event2], 'data') assert event.data._node_data is not None assert event.data['user']['id'] == u'user1'