コード例 #1
0
 def message_callback(self):
     return Mock(name="message_callback")
コード例 #2
0
 def test_contribute_to_stream(self, *, table):
     table.contribute_to_stream(Mock(name='stream', autospec=Stream))
コード例 #3
0
 def test_new_changelog_topic__window_expires(self, *, table):
     table.window = Mock(name='window', autospec=Window)
     table.window.expires = 3600.3
     assert table._new_changelog_topic(retention=None).retention == 3600.3
コード例 #4
0
 def test_should_expire_keys(self, *, table):
     table.window = None
     assert not table._should_expire_keys()
     table.window = Mock(name='window', autospec=Window)
     table.window.expires = 3600
     assert table._should_expire_keys()
コード例 #5
0
 def test__join(self, *, table):
     with pytest.raises(NotImplementedError):
         table._join(Mock(name='join_strategy', autospec=joins.Join))
コード例 #6
0
    async def test_on_start(self, *, app):
        app.finalize = Mock(name="app.finalize")
        await app.on_start()

        app.finalize.assert_called_once_with()
コード例 #7
0
 def test_reset_state(self, *, table):
     data = table._data = Mock(name='_data', autospec=Store)
     table.reset_state()
     data.reset_state.assert_called_once_with()
コード例 #8
0
 def consumer(self):
     return Mock(
         name="consumer",
         autospec=Consumer,
         _drain_messages=AsyncMock(),
     )
コード例 #9
0
 def callback(self):
     return Mock(name="callback")
コード例 #10
0
 def transport(self, *, app):
     return Mock(
         name="transport",
         spec=Transport,
         app=app,
     )
コード例 #11
0
 def test_send_soon(self, *, manager):
     with pytest.raises(NotImplementedError):
         manager.send_soon(Mock(name="FutureMessage"))
コード例 #12
0
 def consumer(self):
     return Mock(
         name="consumer",
         spec=Consumer,
     )
コード例 #13
0
 def partitions_assigned_callback(self):
     return Mock(name="partitions_assigned_callback")
コード例 #14
0
 def partitions_revoked_callback(self):
     return Mock(name="partitions_revoked_callback")
コード例 #15
0
 def test_ack__disabled(self, *, consumer, message, app):
     message.acked = False
     app.topics = Mock(name="app.topics", autospec=Conductor)
     app.topics.acks_enabled_for.return_value = False
     consumer.ack(message)
コード例 #16
0
 def on_P_revoked(self):
     return Mock(name="on_partitions_revoked")
コード例 #17
0
    async def test_on_first_start(self, *, app):
        app.agents = Mock(name="agents")
        app._create_directories = Mock(name="app._create_directories")
        await app.on_first_start()

        app._create_directories.assert_called_once_with()
コード例 #18
0
 def on_P_assigned(self):
     return Mock(name="on_partitions_assigned")
コード例 #19
0
 async def test_wait_for_table_recovery_completed(self, *, app):
     app.tables = Mock()
     app.tables.recovery.started = True
     app.tables.wait_until_recovery_completed = AsyncMock()
     await app._wait_for_table_recovery_completed()
     app.tables.wait_until_recovery_completed.assert_called_once_with()
コード例 #20
0
 def message(self):
     return Mock(name="message", autospec=Message)
コード例 #21
0
 def test_del_old_keys__empty(self, *, table):
     table.window = Mock(name='window')
     table._del_old_keys()
コード例 #22
0
 async def test_on_restart(self, *, consumer):
     consumer._reset_state = Mock()
     consumer.on_init = Mock()
     await consumer.on_restart()
     consumer._reset_state.assert_called_once_with()
     consumer.on_init.assert_called_once_with()
コード例 #23
0
 def test_outer_join(self, *, table):
     table._join = Mock(name='join')
     ret = table.outer_join(User.id, User.name)
     table._join.assert_called_once_with(
         joins.OuterJoin(stream=table, fields=(User.id, User.name)), )
     assert ret is table._join()
コード例 #24
0
 def test__get_active_partitions__when_set(self, *, consumer):
     consumer._active_partitions = {TP1, TP2}
     consumer.assignment = Mock(return_value={TP1})
     assert consumer._get_active_partitions() == {TP1, TP2}
コード例 #25
0
 def test_combine(self, *, table):
     with pytest.raises(NotImplementedError):
         table.combine(Mock(name='joinable', autospec=Stream))
コード例 #26
0
 async def test_on_stop__drainer_done(self, *, fetcher):
     fetcher._drainer = Mock(done=Mock(return_value=True))
     await fetcher.on_stop()
コード例 #27
0
 async def test_remove_from_stream(self, *, table):
     await table.remove_from_stream(Mock(name='stream', autospec=Stream))
コード例 #28
0
 def test_is_changelog_tp(self, *, app, consumer):
     app.tables = Mock(name="tables", autospec=TableManager)
     app.tables.changelog_topics = {"foo", "bar"}
     assert consumer._is_changelog_tp(TP("foo", 31))
     assert consumer._is_changelog_tp(TP("bar", 0))
     assert not consumer._is_changelog_tp(TP("baz", 3))
コード例 #29
0
    def test__maybe_set_key_ttl(self, *, table):
        table._should_expire_keys = Mock(return_value=False)
        table._maybe_set_key_ttl(('k', (100, 110)), 0)

        table._should_expire_keys = Mock(return_value=True)
        table._maybe_set_key_ttl(('k', (100, 110)), 0)
コード例 #30
0
 def test__create_site(self, *, web, app):
     web._new_transport = Mock()
     ret = web._create_site()
     web._new_transport.assert_called_once_with(
         app.conf.web_transport.scheme)
     assert ret is web._new_transport()