Beispiel #1
0
    def test_adding_then_removing_pattern_doesnt_queue_existing_file(self):
        persist = AutoQueuePersist()

        file_one = ModelFile("File.One", True)
        file_one.remote_size = 100
        file_two = ModelFile("File.Two", True)
        file_two.remote_size = 200
        file_three = ModelFile("File.Three", True)
        file_three.remote_size = 300
        file_four = ModelFile("File.Four", True)
        file_four.remote_size = 400
        file_five = ModelFile("File.Five", True)
        file_five.remote_size = 500

        self.initial_model = [
            file_one, file_two, file_three, file_four, file_five
        ]

        # noinspection PyTypeChecker
        auto_queue = AutoQueue(self.context, persist, self.controller)

        auto_queue.process()
        self.controller.queue_command.assert_not_called()

        persist.add_pattern(AutoQueuePattern(pattern="File.One"))
        persist.remove_pattern(AutoQueuePattern(pattern="File.One"))
        auto_queue.process()
        self.controller.queue_command.assert_not_called()
Beispiel #2
0
 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()
Beispiel #3
0
 def test_remove_pattern(self):
     persist = AutoQueuePersist()
     persist.add_pattern(AutoQueuePattern(pattern="one"))
     persist.add_pattern(AutoQueuePattern(pattern="two"))
     persist.remove_pattern(AutoQueuePattern(pattern="one"))
     self.assertEqual({AutoQueuePattern(pattern="two")}, persist.patterns)
     persist.add_pattern(AutoQueuePattern(pattern="one"))
     persist.add_pattern(AutoQueuePattern(pattern="three"))
     persist.remove_pattern(AutoQueuePattern(pattern="two"))
     self.assertEqual(
         {
             AutoQueuePattern(pattern="one"),
             AutoQueuePattern(pattern="three")
         }, persist.patterns)
Beispiel #4
0
 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()
Beispiel #5
0
    def test_removed_pattern_doesnt_queue_new_file(self):
        persist = AutoQueuePersist()
        persist.add_pattern(AutoQueuePattern(pattern="One"))
        persist.add_pattern(AutoQueuePattern(pattern="Two"))
        # noinspection PyTypeChecker
        auto_queue = AutoQueue(self.context, persist, self.controller)

        file_one = ModelFile("File.One", True)
        file_one.remote_size = 100
        self.model_listener.file_added(file_one)
        auto_queue.process()
        command = self.controller.queue_command.call_args[0][0]
        self.assertEqual(Controller.Command.Action.QUEUE, command.action)
        self.assertEqual("File.One", command.filename)
        self.controller.queue_command.reset_mock()

        persist.remove_pattern(AutoQueuePattern(pattern="Two"))

        file_two = ModelFile("File.Two", True)
        file_two.remote_size = 100
        self.model_listener.file_added(file_two)
        auto_queue.process()
        self.controller.queue_command.assert_not_called()