from unittest.mock import MagicMock, patch from miscutils.testing import relative_patch_maker from starlette.testclient import TestClient from selectedtests.app.evergreen import __name__ as helpers_ns NS = "selectedtests.app.controllers.project_test_mappings_controller" helpers_patch = relative_patch_maker(helpers_ns) def ns(relative_name): """Return a full name from a name relative to the tested module"s name space.""" return NS + "." + relative_name @patch(ns("get_correlated_test_mappings")) @helpers_patch("get_evg_project") def test_GET_test_mappings_found_with_threshold_param( get_evg_project_mock, get_correlated_test_mappings_mock, app_client: TestClient): project = "valid-evergreen-project" get_evg_project_mock.return_value = MagicMock(identifier=project) get_correlated_test_mappings_mock.return_value = [ "test_mapping_1", "test_mapping_2" ] response = app_client.get( f"/projects/{project}/test-mappings?changed_files=src/file1.js,src/file2.js&threshold=.5" ) assert response.status_code == 200
""" E-Divisive related tests. """ import numpy as np from miscutils.testing import relative_patch_maker from signal_processing_algorithms.e_divisive import default_implementation from signal_processing_algorithms.e_divisive.calculators import __name__ as patchable patch = relative_patch_maker(patchable) class OldEDivisive(object): """ This is the original O(n^2) E-Divisive implementation as described in the whitepaper. It is here for comparison purposes only and to allow the q values to be generated if further tests are added. NOTE: This is why I have disabled some pylint checks. NOTE: This implementation is purely to provide a 'canonical' implementation for test purposes. It is not efficient and will not be optimized. """ # Implementing change-point detection algorithm from https://arxiv.org/pdf/1306.4933.pdf def qs(self, series: np.ndarray): """ Find Q-Hat values for all candidate change points :param series: the points to process