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')
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()
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
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