def test_update_expected_results_not_path(self): """Test updating when ccextractor path is not correct.""" from mod_regression.update_regression import update_expected_results expected = False response = update_expected_results('/not/a/valid/path') self.assertEqual(response, expected)
def test_update_expected_results_zero_regressions(self, mock_session, mock_os): """Test updating when there are no regression tests.""" from mod_regression.update_regression import update_expected_results mock_os.path.isfile.return_value = True mock_session.return_value.query.return_value.all.return_value = [] expected = True response = update_expected_results('valid/path') self.assertEqual(response, expected)
def run(self, remaining): """Driver function for update command.""" if len(remaining) == 0: print('path to ccextractor is missing') raise MissingPathToCCExtractor path_to_ccex = remaining[0] print(f'path to ccextractor: {path_to_ccex}') if not update_expected_results(path_to_ccex): print('update function errored') raise CCExtractorEndedWithNonZero print('update function finished') return 0
def test_update_expected_results_(self, mock_test, mock_os): """Test updating regression tests.""" from mod_regression.update_regression import update_expected_results mock_os.path.isfile.return_value = True expected = True num_tests = 2 # store number of mock regression tests we have response = update_expected_results('valid/path') self.assertEqual(response, expected) self.assertEqual(mock_test.get_inputfilepath.call_count, num_tests) self.assertEqual(mock_test.get_outputfilepath.call_count, num_tests) self.assertEqual(mock_test.call_count, num_tests) mock_os.makedirs.assert_called_once() self.assertEqual(mock_test.run_ccex.call_count, num_tests)