diff --git a/cdci_data_analysis/pytest_fixtures.py b/cdci_data_analysis/pytest_fixtures.py index c3c4000c..71cb2146 100644 --- a/cdci_data_analysis/pytest_fixtures.py +++ b/cdci_data_analysis/pytest_fixtures.py @@ -1,6 +1,7 @@ # this could be a separate package or/and a pytest plugin from json import JSONDecodeError +import responses import sentry_sdk import yaml @@ -604,7 +605,28 @@ def dispatcher_test_conf_with_gallery_fn(dispatcher_test_conf_fn): '\n product_gallery_url: "http://cdciweb02.astro.unige.ch/mmoda/galleryd"' f'\n product_gallery_secret_key: "{os.getenv("DISPATCHER_PRODUCT_GALLERY_SECRET_KEY", "secret_key")}"' '\n product_gallery_timezone: "Europe/Zurich"' - '\n name_resolver_url: "https://resolver-prod.obsuks1.unige.ch/api/v1.1/byname/{}"' + '\n local_name_resolver_url: "https://resolver-prod.obsuks1.unige.ch/api/v1.1/byname/{}"' + '\n external_name_resolver_url: "http://cdsweb.u-strasbg.fr/cgi-bin/nph-sesame/-oxp/NSV?{}"' + '\n entities_portal_url: "http://cdsportal.u-strasbg.fr/?target={}"' + '\n converttime_revnum_service_url: "https://www.astro.unige.ch/mmoda/dispatch-data/gw/timesystem/api/v1.0/converttime/UTC/{}/REVNUM"') + + yield fn + + +@pytest.fixture +def dispatcher_test_conf_with_gallery_invalid_local_resolver_fn(dispatcher_test_conf_fn): + fn = "test-dispatcher-conf-with-gallery.yaml" + + with open(fn, "w") as f: + with open(dispatcher_test_conf_fn) as f_default: + f.write(f_default.read()) + + f.write('\n product_gallery_options:' + '\n product_gallery_url: "http://cdciweb02.astro.unige.ch/mmoda/galleryd"' + f'\n product_gallery_secret_key: "{os.getenv("DISPATCHER_PRODUCT_GALLERY_SECRET_KEY", "secret_key")}"' + '\n product_gallery_timezone: "Europe/Zurich"' + '\n local_name_resolver_url: "http://invalid_url/"' + '\n external_name_resolver_url: "http://cdsweb.u-strasbg.fr/cgi-bin/nph-sesame/-oxp/NSV?{}"' '\n entities_portal_url: "http://cdsportal.u-strasbg.fr/?target={}"' '\n converttime_revnum_service_url: "https://www.astro.unige.ch/mmoda/dispatch-data/gw/timesystem/api/v1.0/converttime/UTC/{}/REVNUM"') @@ -729,6 +751,11 @@ def dispatcher_test_conf_with_gallery(dispatcher_test_conf_with_gallery_fn): yield yaml.load(open(dispatcher_test_conf_with_gallery_fn), Loader=yaml.SafeLoader)['dispatcher'] +@pytest.fixture +def dispatcher_test_conf_with_gallery_invalid_local_resolver(dispatcher_test_conf_with_gallery_invalid_local_resolver_fn): + yield yaml.load(open(dispatcher_test_conf_with_gallery_invalid_local_resolver_fn), Loader=yaml.SafeLoader)['dispatcher'] + + @pytest.fixture def dispatcher_test_conf_with_vo_options(dispatcher_test_conf_with_vo_options_fn): yield yaml.load(open(dispatcher_test_conf_with_vo_options_fn), Loader=yaml.SafeLoader)['dispatcher'] @@ -1147,6 +1174,20 @@ def dispatcher_live_fixture_with_gallery_no_resolver(pytestconfig, dispatcher_te os.kill(pid, signal.SIGINT) +@pytest.fixture +def dispatcher_live_fixture_with_gallery_invalid_local_resolver(pytestconfig, dispatcher_test_conf_with_gallery_invalid_local_resolver_fn, + dispatcher_debug): + dispatcher_state = start_dispatcher(pytestconfig.rootdir, dispatcher_test_conf_with_gallery_invalid_local_resolver_fn) + + service = dispatcher_state['url'] + pid = dispatcher_state['pid'] + + yield service + + kill_child_processes(pid, signal.SIGINT) + os.kill(pid, signal.SIGINT) + + @pytest.fixture def dispatcher_live_fixture_no_products_url(pytestconfig, dispatcher_test_conf_no_products_url_fn, dispatcher_debug): dispatcher_state = start_dispatcher(pytestconfig.rootdir, dispatcher_test_conf_no_products_url_fn) diff --git a/tests/conftest.py b/tests/conftest.py index f026f5bc..25e5194b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,6 +11,7 @@ dispatcher_live_fixture_no_debug_mode, dispatcher_live_fixture_with_gallery, dispatcher_live_fixture_with_gallery_no_resolver, + dispatcher_live_fixture_with_gallery_invalid_local_resolver, dispatcher_long_living_fixture, gunicorn_dispatcher_long_living_fixture, dispatcher_long_living_fixture_with_matrix_options, @@ -20,8 +21,10 @@ dispatcher_test_conf_with_gallery, dispatcher_test_conf_with_vo_options, dispatcher_test_conf_with_gallery_no_resolver, + dispatcher_test_conf_with_gallery_invalid_local_resolver, dispatcher_test_conf_empty_sentry_fn, dispatcher_test_conf_with_gallery_fn, + dispatcher_test_conf_with_gallery_invalid_local_resolver_fn, dispatcher_test_conf_with_vo_options_fn, dispatcher_test_conf_with_gallery_no_resolver_fn, dispatcher_live_fixture_with_external_products_url,