def engdb(): """Open a connection""" try: engdb = engdb_mast.EngdbMast(base_url=engdb_mast.MAST_BASE_URL) except RuntimeError as exception: pytest.skip( f'Live MAST Engineering Service not available: {exception}') return engdb
def test_notoken(jail_environ): """Check that failure occurs without a token""" try: del os.environ['MAST_API_TOKEN'] except KeyError: pass with pytest.raises(RuntimeError): engdb_mast.EngdbMast()
def test_add_wcs_with_mast(data_file_fromsim, fgsid, tmp_path): """Test using the database""" expected_name = f'add_wcs_with_mast_fgs{fgsid}.fits' # See if access to MAST is available. try: engdb_mast.EngdbMast(base_url=engdb_mast.MAST_BASE_URL) except RuntimeError as exception: pytest.skip( f'Live MAST Engineering Service not available: {exception}') # Execute the operation. try: stp.add_wcs(data_file_fromsim, siaf_path=siaf_path, engdb_url=engdb_mast.MAST_BASE_URL, fgsid=fgsid) except ValueError as exception: pytest.xfail( f'No telemetry exists. Update test to use existing telemetry. Exception: {exception}' ) # Tests with datamodels.Level1bModel(data_file_fromsim) as model: # Save for post-test comparison and update model.save(tmp_path / expected_name) with datamodels.open(DATA_PATH / expected_name) as expected: for meta in METAS_EQUALITY: assert model[meta] == expected[meta] for meta in METAS_ISCLOSE: assert np.isclose(model[meta], expected[meta]) assert word_precision_check(model.meta.wcsinfo.s_region, expected.meta.wcsinfo.s_region)
def test_aliveness(is_alive): """Check connection creation Failure is any failure from instantiation. """ engdb_mast.EngdbMast(base_url=engdb_mast.MAST_BASE_URL, token='dummytoken')
def test_negative_aliveness(): """Ensure failure occurs with a bad url""" with pytest.raises(RuntimeError): engdb_mast.EngdbMast(base_url='https://127.0.0.1/_engdb_mast_test', token='dummytoken')