Пример #1
0
 def test_send_messages_without_resource(self, changelog_meta):
     client = self.make_one(None)
     client._is_running = True
     metadata = [changelog_meta._replace(resource=None, created=True)]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is True
     assert len(self._dummy_connection.queue) == 0
Пример #2
0
 def test_send_messages_without_resource(self, changelog_meta):
     client = self.make_one(None)
     client._is_running = True
     metadata = [changelog_meta._replace(resource=None,
                                         created=True)]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is True
     assert len(self._dummy_connection.queue) == 0
Пример #3
0
 def test_send_messages_nonempty_queue(self, changelog_meta):
     client = self.make_one(None)
     client._is_running = True
     metadata = [changelog_meta._replace(created=True)]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is False
     assert len(self._dummy_connection.queue) == 1
     assert 'created' in self._dummy_connection.queue[0]
Пример #4
0
 def test_send_messages_nonempty_queue(self, changelog_meta):
     client = self.make_one(None)
     client._is_running = True
     metadata = [changelog_meta._replace(created=True)]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is False
     assert len(self._dummy_connection.queue) == 1
     assert 'created' in self._dummy_connection.queue[0]
Пример #5
0
 def test_queue_and_send_messages(self, websocket_client, changelog_meta):
     from pyramid.testing import DummyResource
     context = DummyResource()
     child = DummyResource()
     context['child'] = child
     metadata = [changelog_meta._replace(resource=child)]
     websocket_client._send_messages(metadata)
     assert websocket_client.changelog_metadata_messages_to_send == set()
Пример #6
0
 def test_queue_and_send_messages(self, websocket_client, changelog_meta):
     from pyramid.testing import DummyResource
     context = DummyResource()
     child = DummyResource()
     context['child'] = child
     metadata = [changelog_meta._replace(resource=child)]
     websocket_client._send_messages(metadata)
     assert websocket_client.changelog_metadata_messages_to_send == set()
Пример #7
0
 def test_send_modified_messages_for_backrefs(self, changelog_meta):
     """A modified event is sent for a backreferenced resource."""
     client = self.make_one(None)
     client._is_running = True
     metadata = [changelog_meta._replace(changed_backrefs=True)]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is False
     assert len(self._dummy_connection.queue) == 1
     assert 'modified' in self._dummy_connection.queue[0]
Пример #8
0
 def test_send_modified_messages_for_backrefs(self, changelog_meta):
     """A modified event is sent for a backreferenced resource."""
     client = self.make_one(None)
     client._is_running = True
     metadata = [changelog_meta._replace(changed_backrefs=True)]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is False
     assert len(self._dummy_connection.queue) == 1
     assert 'modified' in self._dummy_connection.queue[0]
Пример #9
0
 def test_send_messages_resource_is_blocked(self, changelog_meta):
     """If a resource is blocked, no event should be sent."""
     client = self.make_one(None)
     client._is_running = True
     resource = DummyResource()
     resource.hidden = True
     metadata = [changelog_meta._replace(modified=True, resource=resource)]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is True
     assert len(self._dummy_connection.queue) == 0
Пример #10
0
 def test_send_messages_created_and_modified(self, changelog_meta):
     """If a resource has been created and then modified, only a
     'created' event should be sent.
     """
     client = self.make_one(None)
     client._is_running = True
     metadata = [changelog_meta._replace(created=True, modified=True)]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is False
     assert len(self._dummy_connection.queue) == 1
     assert 'created' in self._dummy_connection.queue[0]
Пример #11
0
 def test_send_messages_resource_is_blocked(self, changelog_meta):
     """If a resource is blocked, no event should be sent."""
     client = self.make_one(None)
     client._is_running = True
     resource = DummyResource()
     resource.hidden = True
     metadata = [changelog_meta._replace(modified=True,
                                         resource=resource)]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is True
     assert len(self._dummy_connection.queue) == 0
Пример #12
0
 def test_send_messages_invisible(self, changelog_meta):
     """No event is sent for invisible resources."""
     from adhocracy_core.interfaces import VisibilityChange
     client = self.make_one(None)
     client._is_running = True
     metadata = [changelog_meta._replace(
         modified=True,
         visibility=VisibilityChange.invisible)]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is True
     assert len(self._dummy_connection.queue) == 0
Пример #13
0
 def test_send_messages_invisible(self, changelog_meta):
     """No event is sent for invisible resources."""
     from adhocracy_core.interfaces import VisibilityChange
     client = self.make_one(None)
     client._is_running = True
     metadata = [
         changelog_meta._replace(modified=True,
                                 visibility=VisibilityChange.invisible)
     ]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is True
     assert len(self._dummy_connection.queue) == 0
Пример #14
0
 def test_send_messages_changed_backrefs_and_modified(self, changelog_meta):
     """No additional event is sent if a backreferenced resource
     has modified anyway.
     """
     client = self.make_one(None)
     client._is_running = True
     metadata = [changelog_meta._replace(modified=True,
                                         changed_backrefs=True)]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is False
     assert len(self._dummy_connection.queue) == 1
     assert 'modified' in self._dummy_connection.queue[0]
Пример #15
0
 def test_send_messages_concealed(self, changelog_meta):
     """If a resource has been concealed, a 'removed' event should be sent.
     """
     from adhocracy_core.interfaces import VisibilityChange
     client = self.make_one(None)
     client._is_running = True
     metadata = [changelog_meta._replace(
         visibility=VisibilityChange.concealed)]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is False
     assert len(self._dummy_connection.queue) == 1
     assert 'removed' in self._dummy_connection.queue[0]
Пример #16
0
 def test_send_messages_created_and_modified(self, changelog_meta):
     """If a resource has been created and then modified, only a
     'created' event should be sent.
     """
     client = self.make_one(None)
     client._is_running = True
     metadata = [changelog_meta._replace(created=True,
                                         modified=True)]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is False
     assert len(self._dummy_connection.queue) == 1
     assert 'created' in self._dummy_connection.queue[0]
Пример #17
0
 def test_send_messages_changed_backrefs_and_modified(self, changelog_meta):
     """No additional event is sent if a backreferenced resource
     has modified anyway.
     """
     client = self.make_one(None)
     client._is_running = True
     metadata = [
         changelog_meta._replace(modified=True, changed_backrefs=True)
     ]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is False
     assert len(self._dummy_connection.queue) == 1
     assert 'modified' in self._dummy_connection.queue[0]
Пример #18
0
 def test_send_messages_changed_descendants_and_modified(self, changelog_meta):
     """If a resource has changed_descendants amd is modified, both
      events should be sent.
     """
     client = self.make_one(None)
     client._is_running = True
     metadata = [changelog_meta._replace(changed_descendants=True,
                                         modified=True)]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is False
     assert len(self._dummy_connection.queue) == 2
     assert 'modified' in self._dummy_connection.queue[0]
     assert 'changed_descendants' in self._dummy_connection.queue[1]
Пример #19
0
 def test_send_messages_concealed(self, changelog_meta):
     """If a resource has been concealed, a 'removed' event should be sent.
     """
     from adhocracy_core.interfaces import VisibilityChange
     client = self.make_one(None)
     client._is_running = True
     metadata = [
         changelog_meta._replace(visibility=VisibilityChange.concealed)
     ]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is False
     assert len(self._dummy_connection.queue) == 1
     assert 'removed' in self._dummy_connection.queue[0]
Пример #20
0
 def test_send_messages_changed_descendants_and_modified(
         self, changelog_meta):
     """If a resource has changed_descendants amd is modified, both
      events should be sent.
     """
     client = self.make_one(None)
     client._is_running = True
     metadata = [
         changelog_meta._replace(changed_descendants=True, modified=True)
     ]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is False
     assert len(self._dummy_connection.queue) == 2
     assert 'modified' in self._dummy_connection.queue[0]
     assert 'changed_descendants' in self._dummy_connection.queue[1]
Пример #21
0
 def changelog_meta(self, changelog_meta, pool_graph):
     child = self._make_resource(parent=pool_graph)
     return changelog_meta._replace(resource=child)
Пример #22
0
 def changelog_meta(self, changelog_meta, pool_graph):
     child = self._make_resource(parent=pool_graph)
     return changelog_meta._replace(resource=child)
Пример #23
0
 def test_send_messages_if_not_running(self, changelog_meta):
     client = self.make_one(None)
     client._is_running = False
     metadata = [changelog_meta._replace(created=True)]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is True
Пример #24
0
 def test_send_messages_if_not_running(self, changelog_meta):
     client = self.make_one(None)
     client._is_running = False
     metadata = [changelog_meta._replace(created=True)]
     client.send_messages(metadata)
     assert self._dummy_connection.nothing_sent is True