def test_adds_item_to_inbox(self, mocker): inbox = SyncClientInbox() assert inbox.empty() item = mocker.MagicMock() inbox.put(item) assert not inbox.empty() assert item in inbox
def test_check_item_is_in_inbox(self, mocker): inbox = SyncClientInbox() assert inbox.empty() item = mocker.MagicMock() assert item not in inbox inbox.put(item) assert item in inbox
def test_check_if_empty(self, mocker): inbox = SyncClientInbox() assert inbox.empty() item = mocker.MagicMock() inbox.put(item) assert not inbox.empty() inbox.get() assert inbox.empty()
def test_removes_item_from_inbox_if_already_there(self, mocker): inbox = SyncClientInbox() assert inbox.empty() item = mocker.MagicMock() inbox.put(item) assert not inbox.empty() retrieved_item = inbox.get() assert retrieved_item is item assert inbox.empty()
def test_operates_according_to_FIFO(self, mocker): inbox = SyncClientInbox() item1 = mocker.MagicMock() item2 = mocker.MagicMock() item3 = mocker.MagicMock() inbox.put(item1) inbox.put(item2) inbox.put(item3) assert inbox.get() is item1 assert inbox.get() is item2 assert inbox.get() is item3
def test_can_clear_all_items(self, mocker): inbox = SyncClientInbox() 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()