Exemplo n.º 1
0
    def test_job_validate_exception(self, mock_print, mock_job_template_loader,
                                    mock_bespin_api, mock_config_file):
        mock_infile = Mock()
        mock_job_template = mock_job_template_loader.return_value.create_job_template.return_value
        mock_job_template.validate.side_effect = UserInputException("Bad data")

        commands = Commands(self.version_str, self.user_agent_str)
        with self.assertRaises(UserInputException):
            commands.job_validate(job_template_infile=mock_infile)

        mock_print.assert_called_with('ERROR: Job template is invalid.')
Exemplo n.º 2
0
    def test_job_validate(self, mock_print, mock_job_template_loader,
                          mock_bespin_api, mock_config_file):
        mock_infile = Mock()

        commands = Commands(self.version_str, self.user_agent_str)
        commands.job_validate(job_template_infile=mock_infile)

        mock_job_template_loader.assert_called_with(mock_infile)
        mock_job_template = mock_job_template_loader.return_value.create_job_template.return_value
        mock_job_template.validate.assert_called_with(
            mock_bespin_api.return_value)
        mock_print.assert_called_with('Job file is valid.')