def test_download_build_log_file_test_not_found(self, mock_test): """Try to download build log for invalid test.""" from mod_test.controllers import (TestNotFoundException, download_build_log_file) mock_test.query.filter.return_value.first.return_value = None with self.assertRaises(TestNotFoundException): download_build_log_file(1) mock_test.query.filter.assert_called_once()
def test_download_build_log_file_log_not_file(self, mock_test, mock_os): """Try to download build log for invalid file path.""" from mod_test.controllers import (TestNotFoundException, download_build_log_file) mock_os.path.isfile.side_effect = TestNotFoundException('msg') with self.assertRaises(TestNotFoundException): download_build_log_file('1') mock_test.query.filter.assert_called_once() mock_os.path.isfile.assert_called_once()
def test_download_build_log_file(self, mock_serve, mock_test, mock_os): """Try to download build log.""" from mod_test.controllers import (TestNotFoundException, download_build_log_file) response = download_build_log_file('1') self.assertEqual(response, mock_serve()) mock_test.query.filter.assert_called_once() mock_os.path.isfile.assert_called_once()