def test_listener_pattern_removed_non_existing(self): listener = TestAutoQueuePersistListener() listener.pattern_removed = MagicMock() persist = AutoQueuePersist() persist.add_pattern(AutoQueuePattern(pattern="one")) persist.add_pattern(AutoQueuePattern(pattern="two")) persist.add_pattern(AutoQueuePattern(pattern="three")) persist.add_listener(listener) persist.remove_pattern(AutoQueuePattern(pattern="four")) listener.pattern_removed.assert_not_called()
def test_listener_pattern_added_duplicate(self): listener = TestAutoQueuePersistListener() listener.pattern_added = MagicMock() persist = AutoQueuePersist() persist.add_listener(listener) persist.add_pattern(AutoQueuePattern(pattern="one")) listener.pattern_added.assert_called_once_with( AutoQueuePattern(pattern="one")) listener.pattern_added.reset_mock() persist.add_pattern(AutoQueuePattern(pattern="one")) listener.pattern_added.assert_not_called()
def test_listener_pattern_removed(self): listener = TestAutoQueuePersistListener() listener.pattern_removed = MagicMock() persist = AutoQueuePersist() persist.add_pattern(AutoQueuePattern(pattern="one")) persist.add_pattern(AutoQueuePattern(pattern="two")) persist.add_pattern(AutoQueuePattern(pattern="three")) persist.add_listener(listener) persist.remove_pattern(AutoQueuePattern(pattern="one")) listener.pattern_removed.assert_called_once_with( AutoQueuePattern(pattern="one")) listener.pattern_removed.reset_mock() persist.remove_pattern(AutoQueuePattern(pattern="two")) listener.pattern_removed.assert_called_once_with( AutoQueuePattern(pattern="two")) listener.pattern_removed.reset_mock()