コード例 #1
0
ファイル: test_conductor.py プロジェクト: zhouyuking/faust
    async def test_update_indices(self, *, con):
        topic1 = Mock(name='topic1', autospec=Topic)
        topic1.acks = False
        topic1.topics = ['t1']
        topic1.internal = False
        topic2 = Mock(name='topic2', autospec=Topic)
        topic2.acks = True
        topic2.topics = ['t2']
        topic2.internal = True
        topic2.maybe_declare = AsyncMock(name='maybe_declare')
        con._topics = {topic1, topic2}

        await con._update_indices()
        topic1.maybe_declare.assert_not_called()
        topic2.maybe_declare.assert_called_once_with()
        assert 't1' not in con._acking_topics
        assert 't2' in con._acking_topics
        assert con._topic_name_index['t1'] == {topic1}
        assert con._topic_name_index['t2'] == {topic2}
コード例 #2
0
    async def test_update_indices(self, *, con):
        topic1 = Mock(name="topic1", autospec=Topic)
        topic1.acks = False
        topic1.topics = ["t1"]
        topic1.internal = False
        topic2 = Mock(name="topic2", autospec=Topic)
        topic2.acks = True
        topic2.topics = ["t2"]
        topic2.internal = True
        topic2.maybe_declare = AsyncMock(name="maybe_declare")
        con._topics = {topic1, topic2}

        await con._update_indices()
        topic1.maybe_declare.assert_not_called()
        topic2.maybe_declare.assert_called_once_with()
        assert "t1" not in con._acking_topics
        assert "t2" in con._acking_topics
        assert con._topic_name_index["t1"] == {topic1}
        assert con._topic_name_index["t2"] == {topic2}