#! /usr/bin/env python
"""Tests for the ``engineering_database`` module.
Authors
-------
- Johannes Sahlmann
Use
---
These tests can be run via the command line (omit the ``-s`` to
suppress verbose output to ``stdout``):
::
pytest -s test_edb.py
"""
import os
from astropy.time import Time
import pytest
# Determine if tests are being run on Github Actions
ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~')
[docs]@pytest.mark.skipif(ON_GITHUB_ACTIONS, reason='Requires access to central storage.')
def test_get_mnemonic():
"""Test the query of a single mnemonic."""
from jwql.edb.engineering_database import get_mnemonic
mnemonic_identifier = 'IMIR_HK_ICE_SEC_VOLT4'
start_time = Time('2019-01-16 00:00:00.000', format='iso')
end_time = Time('2019-01-16 00:01:00.000', format='iso')
mnemonic = get_mnemonic(mnemonic_identifier, start_time, end_time)
assert len(mnemonic.data) == mnemonic.meta['paging']['rows']
[docs]@pytest.mark.skipif(ON_GITHUB_ACTIONS, reason='Requires access to central storage.')
def test_get_mnemonic_info():
"""Test retrieval of mnemonic info."""
from jwql.edb.engineering_database import get_mnemonic_info
mnemonic_identifier = 'IMIR_HK_ICE_SEC_VOLT4'
info = get_mnemonic_info(mnemonic_identifier)
assert 'subsystem' in info.keys()
[docs]@pytest.mark.skipif(ON_GITHUB_ACTIONS, reason='Requires access to central storage.')
def test_get_mnemonics():
"""Test the query of a list of mnemonics."""
from jwql.edb.engineering_database import get_mnemonics
mnemonics = ['SA_ZFGOUTFOV', 'SA_ZFGBADCNT']
start_time = Time(2018.0, format='decimalyear')
end_time = Time(2018.1, format='decimalyear')
mnemonic_dict = get_mnemonics(mnemonics, start_time, end_time)
assert len(mnemonic_dict) == len(mnemonics)