Skip to content

Commit

Permalink
extended tests
Browse files Browse the repository at this point in the history
  • Loading branch information
burnout87 committed Oct 2, 2024
1 parent 6b79847 commit bfcd77d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
43 changes: 42 additions & 1 deletion cdci_data_analysis/pytest_fixtures.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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"')

Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit bfcd77d

Please sign in to comment.