From 7c65976279498046c8e578671b2b8e659a924c94 Mon Sep 17 00:00:00 2001 From: Karan Shah Date: Tue, 26 May 2020 13:41:17 +0530 Subject: [PATCH] Updated model service detectors url --- tests/test_cli.py | 30 +++++++++++------------ tests/test_constant_threshold_detector.py | 4 +-- tests/test_detector_client.py | 2 +- tests/test_metrics.py | 22 ++++++++--------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 58c69e6..4c8971d 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -21,10 +21,10 @@ def test_cli_build_detectors_already_exists(caplog): responses.add(responses.POST, "http://modelservice/api/detectorMappings/findMatchingByTags", json=FIND_BY_MATCHING_TAGS_MOCK_RESPONSE, status=200) - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", json=MOCK_DETECTORS[0], status=200) - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4", json=MOCK_DETECTORS[1], status=200) metric_configs, exit_code = read_config_file("./tests/data/metric-config.json") @@ -50,10 +50,10 @@ def test_cli_build_new_detectors(caplog): responses.add(responses.POST, "http://modelservice/api/detectorMappings", json=[], status=200) - responses.add(responses.POST, "http://modelservice/api/v2/detectors", + responses.add(responses.POST, "http://modelservice/api/v3/detectors", body="4fdc3395-e969-449a-a306-201db183c6d7", status=201) - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", json=MOCK_DETECTORS[0], status=200) responses.add( @@ -63,10 +63,10 @@ def test_cli_build_new_detectors(caplog): status=200, ) # error_count - responses.add(responses.POST, "http://modelservice/api/v2/detectors", + responses.add(responses.POST, "http://modelservice/api/v3/detectors", body="47a0661d-aceb-4ef2-bf06-0828f28631b4", status=201) - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4", json=MOCK_DETECTORS[1], status=200) responses.add( @@ -76,10 +76,10 @@ def test_cli_build_new_detectors(caplog): status=200, ) # success_rate - responses.add(responses.POST, "http://modelservice/api/v2/detectors", + responses.add(responses.POST, "http://modelservice/api/v3/detectors", body="16769303-a950-4d0f-a5a6-8d00eef886ec", status=201) - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=16769303-a950-4d0f-a5a6-8d00eef886ec", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=16769303-a950-4d0f-a5a6-8d00eef886ec", json=MOCK_DETECTORS[2], status=200) responses.add( @@ -89,10 +89,10 @@ def test_cli_build_new_detectors(caplog): status=200, ) # latency - responses.add(responses.POST, "http://modelservice/api/v2/detectors", + responses.add(responses.POST, "http://modelservice/api/v3/detectors", body="5afc2bb3-4a5b-4a4b-8e30-890d67904588", status=201) - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=5afc2bb3-4a5b-4a4b-8e30-890d67904588", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=5afc2bb3-4a5b-4a4b-8e30-890d67904588", json=MOCK_DETECTORS[3], status=200) responses.add( @@ -117,10 +117,10 @@ def test_cli_disable_metric_detectors(caplog): responses.add(responses.POST, "http://modelservice/api/detectorMappings/findMatchingByTags", json=FIND_BY_MATCHING_TAGS_MOCK_RESPONSE, status=200) - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", json=MOCK_DETECTORS[0], status=200) - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4", json=MOCK_DETECTORS[1], status=200) responses.add(responses.POST, "http://modelservice/api/detectorMappings/search", @@ -133,9 +133,9 @@ def test_cli_disable_metric_detectors(caplog): status=200) responses.add(responses.PUT, "http://modelservice/api/detectorMappings/disable?id=6XeANXABlK1-eG-Fo78V", status=200) - responses.add(responses.POST, "http://modelservice/api/v2/detectors/toggleDetector?enabled=false&uuid=4fdc3395-e969-449a-a306-201db183c6d7", + responses.add(responses.POST, "http://modelservice/api/v3/detectors/toggleDetector?enabled=false&uuid=4fdc3395-e969-449a-a306-201db183c6d7", status=200) - responses.add(responses.POST, "http://modelservice/api/v2/detectors/toggleDetector?enabled=false&uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4", + responses.add(responses.POST, "http://modelservice/api/v3/detectors/toggleDetector?enabled=false&uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4", status=200) metric_configs, exit_code = read_config_file("./tests/data/metric-config-request-count.json") disable_exit_code = disable_detectors_for_metric_configs(metric_configs) @@ -155,7 +155,7 @@ def test_cli_train_metric_detectors_sparse_data(caplog): "lookupTimeInMillis": 2 }, status=200) - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=5afc2bb3-4a5b-4a4b-8e30-890d67904588", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=5afc2bb3-4a5b-4a4b-8e30-890d67904588", json=MOCK_DETECTORS[3], status=200) responses.add( diff --git a/tests/test_constant_threshold_detector.py b/tests/test_constant_threshold_detector.py index 8662207..0ab4f80 100644 --- a/tests/test_constant_threshold_detector.py +++ b/tests/test_constant_threshold_detector.py @@ -175,10 +175,10 @@ def test_train_detector_with_invalid_sample_size_raises_build_error(mock_metric) responses.add(responses.POST, "http://modelservice/api/detectorMappings", json=[], status=200) - responses.add(responses.POST, "http://modelservice/api/v2/detectors", + responses.add(responses.POST, "http://modelservice/api/v3/detectors", body="4fdc3395-e969-449a-a306-201db183c6d7", status=201) - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", json=MOCK_DETECTORS[0], status=200) diff --git a/tests/test_detector_client.py b/tests/test_detector_client.py index cb73793..07157bb 100644 --- a/tests/test_detector_client.py +++ b/tests/test_detector_client.py @@ -21,7 +21,7 @@ @responses.activate def test_detector_client_get_detector(mock_metric): - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", json=MOCK_DETECTORS[0], status=200) detector_client = DetectorClient() diff --git a/tests/test_metrics.py b/tests/test_metrics.py index 8df81b7..5d26055 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -18,10 +18,10 @@ def test_detector_client_list_detectors_for_metric(mock_metric): responses.add(responses.POST, "http://modelservice/api/detectorMappings/findMatchingByTags", json=FIND_BY_MATCHING_TAGS_MOCK_RESPONSE, status=200) - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", json=MOCK_DETECTORS[0], status=200) - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4", json=MOCK_DETECTORS[1], status=200) detector_client = DetectorClient() @@ -40,10 +40,10 @@ def test_build_metric_detectors(mock_metric): responses.add(responses.POST, "http://modelservice/api/detectorMappings", json=[], status=200) - responses.add(responses.POST, "http://modelservice/api/v2/detectors", + responses.add(responses.POST, "http://modelservice/api/v3/detectors", body="4fdc3395-e969-449a-a306-201db183c6d7", status=201) - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", json=MOCK_DETECTORS[0], status=200) @@ -66,10 +66,10 @@ def test_delete_metric_detectors(mock_metric): responses.add(responses.POST, "http://modelservice/api/detectorMappings/findMatchingByTags", json=FIND_BY_MATCHING_TAGS_MOCK_RESPONSE, status=200) - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", json=MOCK_DETECTORS[0], status=200) - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4", json=MOCK_DETECTORS[1], status=200) responses.add(responses.POST, "http://modelservice/api/detectorMappings/search", @@ -82,9 +82,9 @@ def test_delete_metric_detectors(mock_metric): status=200) responses.add(responses.DELETE, "http://modelservice/api/detectorMappings?id=6XeANXABlK1-eG-Fo78V", status=200) - responses.add(responses.DELETE, "http://modelservice/api/v2/detectors?uuid=4fdc3395-e969-449a-a306-201db183c6d7", + responses.add(responses.DELETE, "http://modelservice/api/v3/detectors?uuid=4fdc3395-e969-449a-a306-201db183c6d7", status=200) - responses.add(responses.DELETE, "http://modelservice/api/v2/detectors?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4", + responses.add(responses.DELETE, "http://modelservice/api/v3/detectors?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4", status=200) test_metric = mock_metric(data=[5, 4, 7, 9, 15, 1, 0]) assert len(test_metric.detectors) == 2 @@ -102,10 +102,10 @@ def test_train_metric_detectors(mock_metric): responses.add(responses.POST, "http://modelservice/api/detectorMappings/findMatchingByTags", json=FIND_BY_MATCHING_TAGS_MOCK_RESPONSE, status=200) - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7", json=MOCK_DETECTORS[0], status=200) - responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4", + responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4", json=MOCK_DETECTORS[1], status=200) def validate_update_request(request): @@ -116,7 +116,7 @@ def validate_update_request(request): assert isclose(thresholds["lowerWeak"], -9.48, rel_tol=0.01) assert isclose(thresholds["lowerStrong"], -14.59, rel_tol=0.01) return (200, {}, None) - responses.add_callback(responses.PUT, "http://modelservice/api/v2/detectors?uuid=4fdc3395-e969-449a-a306-201db183c6d7", + responses.add_callback(responses.PUT, "http://modelservice/api/v3/detectors?uuid=4fdc3395-e969-449a-a306-201db183c6d7", callback=validate_update_request) test_metric = mock_metric(data=[5, 4, 7, 9, 15, 1, 0]) assert len(test_metric.detectors) == 2