Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test rmf #286

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added tests/test_data/isgri_rmf_Crab.fits
Binary file not shown.
29 changes: 29 additions & 0 deletions tests/test_data_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
from astropy.table import Table
from matplotlib import pyplot as plt

import base64
import pickle

secret_key = 'secretkey_test'
default_exp_time = int(time.time()) + 5000
default_token_payload = dict(
Expand All @@ -33,6 +36,32 @@
mssub=True
)


def test_rmf():
isgri_rmf_dp = NumpyDataProduct.from_fits_file("tests/test_data/isgri_rmf_Crab.fits")

Check warning on line 41 in tests/test_data_products.py

View check run for this annotation

Codecov / codecov/patch

tests/test_data_products.py#L41

Added line #L41 was not covered by tests

encoded_numpy_data_prod = isgri_rmf_dp.encode()
decoded_numpy_data_prod = NumpyDataProduct.decode(encoded_numpy_data_prod)

Check warning on line 44 in tests/test_data_products.py

View check run for this annotation

Codecov / codecov/patch

tests/test_data_products.py#L43-L44

Added lines #L43 - L44 were not covered by tests

# this is the higher-level call causing the above error in nb2workflow
_hdul = fits.HDUList()
for ID, _d in enumerate(decoded_numpy_data_prod.data_unit):
print(ID, _d.header['EXTNAME'])
try:
_hdul.append(_d.to_fits_hdu())
except Exception as ee:

Check warning on line 52 in tests/test_data_products.py

View check run for this annotation

Codecov / codecov/patch

tests/test_data_products.py#L47-L52

Added lines #L47 - L52 were not covered by tests
# print(ee)
raise Exception(ee)

Check warning on line 54 in tests/test_data_products.py

View check run for this annotation

Codecov / codecov/patch

tests/test_data_products.py#L54

Added line #L54 was not covered by tests

# this reproduces the commands done inside the above call (?)
binarys = base64.b64decode(encoded_numpy_data_prod['data_unit_list'][2]['binarys'])
try:
pickle.loads(binarys, encoding='bytes')
print('pickle test successful')
except Exception as ee:
raise Exception(ee)

Check warning on line 62 in tests/test_data_products.py

View check run for this annotation

Codecov / codecov/patch

tests/test_data_products.py#L57-L62

Added lines #L57 - L62 were not covered by tests


# TODO: adapt to new product types and implement corresponding tests
def encode_decode(ndp: typing.Union[NumpyDataProduct,
ODAAstropyTable,
Expand Down
Loading