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

Mnt nist tests #2921

Merged
merged 2 commits into from
Jan 8, 2024
Merged
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
22 changes: 12 additions & 10 deletions astroquery/nist/tests/test_nist_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,50 @@

import pytest

from ... import nist
from astroquery.nist import Nist


@pytest.mark.remote_data
class TestNist:

def test_query_async(self):
response = nist.core.Nist.query_async(4000 * u.AA, 7000 * u.AA)
response = Nist.query_async(4000 * u.AA, 7000 * u.AA)
assert response is not None
assert response.status_code == 200

def test_query(self):
result = nist.core.Nist.query(4000 * u.AA, 7000 * u.AA)
result = Nist.query(4000 * u.AA, 7000 * u.AA)
assert isinstance(result, Table)

# check that no javascript was left in the table
# (regression test for 1355)
assert set(result['TP']) == set(['T8637', 'T7771'])

assert set(result['TP'].filled()) == set(['T8637', 'T7771', 'N/A'])

def test_unescape_html(self):
response = nist.core.Nist.query_async(4333 * u.AA, 4334 * u.AA, linename="V I")
response = Nist.query_async(4333 * u.AA, 4334 * u.AA, linename="V I")
assert '†' in response.text
# check that Unicode characters have been properly unescaped from their
# raw HTML code equivalents during parsing
response = nist.core.Nist._parse_result(response)
response = Nist._parse_result(response)
assert any('†' in s for s in response['Ei Ek'])

def test_query_limits(self):
result = nist.core.Nist.query(4101 * u.AA, 4103 * u.AA)
result = Nist.query(4101 * u.AA, 4103 * u.AA)
# check that min, max wavelengths are appropriately set
assert result['Ritz'].min() >= 4101
assert result['Ritz'].max() <= 4103

# check that the units are respected
result = nist.core.Nist.query(410.1 * u.nm, 410.3 * u.nm)
result = Nist.query(410.1 * u.nm, 410.3 * u.nm)
assert result['Ritz'].min() >= 410.1
assert result['Ritz'].max() <= 410.3

result = nist.core.Nist.query(0.4101 * u.um, 0.4103 * u.um)
result = Nist.query(0.4101 * u.um, 0.4103 * u.um)
assert result['Ritz'].min() >= 0.4101
assert result['Ritz'].max() <= 0.4103

# check that non-supported units default to angstroms
result = nist.core.Nist.query(4101 * 1e-10 * u.m, 4103 * 1e-10 * u.m)
result = Nist.query(4101 * 1e-10 * u.m, 4103 * 1e-10 * u.m)
assert result['Ritz'].min() >= 4101
assert result['Ritz'].max() <= 4103