Ejemplo n.º 1
0
 def setup_controller(self):
     self.collection = mock.create_autospec(
         job.JobCollection,
         enable=mock.Mock(),
         disable=mock.Mock(),
     )
     self.controller = JobCollectionController(self.collection)
Ejemplo n.º 2
0
class TestJobCollectionController(TestCase):
    @setup
    def setup_controller(self):
        self.collection = mock.create_autospec(
            JobCollection,
            enable=mock.Mock(),
            disable=mock.Mock(),
        )
        self.controller = JobCollectionController(self.collection)

    def test_handle_command_unknown(self):
        with self.assertRaises(UnknownCommandError):
            self.controller.handle_command('enableall')
            self.controller.handle_command('disableall')
Ejemplo n.º 3
0
class JobCollectionControllerTestCase(TestCase):
    @setup
    def setup_controller(self):
        self.collection = mock.create_autospec(job.JobCollection,
                                               enable=mock.Mock(),
                                               disable=mock.Mock())
        self.controller = JobCollectionController(self.collection)

    def test_handle_command_enabled(self):
        self.controller.handle_command('enableall')
        self.collection.enable.assert_called_with()

    def test_handle_command_disable(self):
        self.controller.handle_command('disableall')
        self.collection.disable.assert_called_with()
Ejemplo n.º 4
0
class JobCollectionControllerTestCase(TestCase):

    @setup
    def setup_controller(self):
        self.collection     = mock.create_autospec(job.JobCollection,
                                enable=mock.Mock(), disable=mock.Mock())
        self.controller     = JobCollectionController(self.collection)

    def test_handle_command_enabled(self):
        self.controller.handle_command('enableall')
        self.collection.enable.assert_called_with()

    def test_handle_command_disable(self):
        self.controller.handle_command('disableall')
        self.collection.disable.assert_called_with()
Ejemplo n.º 5
0
 def setup_controller(self):
     self.collection = mock.create_autospec(
         JobCollection,
         enable=mock.Mock(),
         disable=mock.Mock(),
     )
     self.controller = JobCollectionController(self.collection)
Ejemplo n.º 6
0
class TestJobCollectionController:
    @pytest.fixture(autouse=True)
    def setup_controller(self):
        self.collection = mock.create_autospec(
            JobCollection,
            enable=mock.Mock(),
            disable=mock.Mock(),
        )
        self.controller = JobCollectionController(self.collection)

    def test_handle_command_unknown(self):
        with pytest.raises(UnknownCommandError):
            self.controller.handle_command('enableall')
            self.controller.handle_command('disableall')

    def test_handle_command_move_non_existing_job(self):
        self.collection.get_names.return_value = []
        result = self.controller.handle_command('move',
                                                old_name='old.test',
                                                new_name='new.test')
        assert "doesn't exist" in result

    def test_handle_command_move_to_existing_job(self):
        self.collection.get_names.return_value = ['old.test', 'new.test']
        result = self.controller.handle_command('move',
                                                old_name='old.test',
                                                new_name='new.test')
        assert "exists already" in result

    def test_handle_command_move(self):
        self.collection.get_names.return_value = ['old.test']
        result = self.controller.handle_command('move',
                                                old_name='old.test',
                                                new_name='new.test')
        assert "Error" not in result
Ejemplo n.º 7
0
class TestJobCollectionController:
    @pytest.fixture(autouse=True)
    def setup_controller(self):
        self.collection = mock.create_autospec(
            JobCollection,
            enable=mock.Mock(),
            disable=mock.Mock(),
        )
        self.controller = JobCollectionController(self.collection)

    def test_handle_command_unknown(self):
        with pytest.raises(UnknownCommandError):
            self.controller.handle_command('enableall')
            self.controller.handle_command('disableall')

    def test_handle_command_move_non_existing_job(self):
        self.collection.get_names.return_value = []
        result = self.controller.handle_command(
            'move', old_name='old.test', new_name='new.test'
        )
        assert "doesn't exist" in result

    def test_handle_command_move_to_existing_job(self):
        self.collection.get_names.return_value = ['old.test', 'new.test']
        result = self.controller.handle_command(
            'move', old_name='old.test', new_name='new.test'
        )
        assert "exists already" in result

    def test_handle_command_move(self):
        self.collection.get_names.return_value = ['old.test']
        result = self.controller.handle_command(
            'move', old_name='old.test', new_name='new.test'
        )
        assert "Error" not in result