コード例 #1
0
    def test_can_clear_all_items(self, mocker):
        inbox = AsyncClientInbox()
        item1 = mocker.MagicMock()
        item2 = mocker.MagicMock()
        item3 = mocker.MagicMock()
        inbox._put(item1)
        inbox._put(item2)
        inbox._put(item3)
        assert not inbox.empty()

        inbox.clear()
        assert inbox.empty()
コード例 #2
0
    async def test_operates_according_to_FIFO(self, mocker):
        inbox = AsyncClientInbox()
        item1 = mocker.MagicMock()
        item2 = mocker.MagicMock()
        item3 = mocker.MagicMock()
        inbox._put(item1)
        inbox._put(item2)
        inbox._put(item3)

        assert await inbox.get() is item1
        assert await inbox.get() is item2
        assert await inbox.get() is item3
コード例 #3
0
    async def test_removes_item_from_inbox_if_already_there(self, mocker):
        inbox = AsyncClientInbox()
        assert inbox.empty()
        item = mocker.MagicMock()
        inbox._put(item)
        assert not inbox.empty()
        retrieved_item = await inbox.get()
        assert retrieved_item is item
        assert inbox.empty()

        await asyncio.sleep(0.01
                            )  # Do this to prevent RuntimeWarning from janus
コード例 #4
0
    async def test_operates_according_to_FIFO(self, mocker):
        inbox = AsyncClientInbox()
        item1 = mocker.MagicMock()
        item2 = mocker.MagicMock()
        item3 = mocker.MagicMock()
        inbox._put(item1)
        inbox._put(item2)
        inbox._put(item3)

        assert await inbox.get() is item1
        assert await inbox.get() is item2
        assert await inbox.get() is item3

        await asyncio.sleep(0.01)  # Do this to prevent RuntimeWarning from janus