Skip to content

Commit

Permalink
TST: added unit tests for NoRP data
Browse files Browse the repository at this point in the history
Added unit tests for the new NoRP support functions and a data file to test mock downloads for the new Instrument.
  • Loading branch information
aburrell committed Aug 14, 2024
1 parent 81134b9 commit 9b8b48b
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pysatSpaceWeather/tests/test_data/TYKW-NoRP_dailyflux.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
TYKW-NoRP solar daily flux (1951-11-02 -- 1951-11-06)
Date,1 GHz,2 GHz,3.75 GHz,9.4 GHz
"1951-11-02",NaN,NaN,NaN,NaN
"1951-11-03",NaN,NaN,NaN,NaN
"1951-11-04",NaN,NaN,NaN,NaN
"1951-11-05",NaN,NaN,NaN,NaN
"1951-11-06",NaN,NaN,115.000,NaN
55 changes: 55 additions & 0 deletions pysatSpaceWeather/tests/test_methods_norp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env python
# Full license can be found in License.md
# Full author list can be found in .zenodo.json file
# DOI:10.5281/zenodo.3986138
# ----------------------------------------------------------------------------
"""Integration and unit test suite for NoRP methods."""

import pytest

from pysatSpaceWeather.instruments.methods import norp as mm_norp


class TestNoRPMethods(object):
"""Test class for NoRP methods."""

def setup_method(self):
"""Create a clean testing setup."""
self.out = None
return

def teardown_method(self):
"""Clean up previous testing setup."""
del self.out
return

def test_acknowledgements(self):
"""Test the NoRP acknowledgements."""
self.out = mm_norp.acknowledgements()
assert self.out.find('NoRP') >= 0
return

@pytest.mark.parametrize('name,tag', [('rf', 'daily')])
def test_references(self, name, tag):
"""Test the references for a NoRP instrument.
Parameters
----------
name : str
Instrument name
tag : str
Instrument tag
"""
self.out = mm_norp.references(name, tag)
assert self.out.find('Toyokawa Observatory') > 0
return

def test_references_bad_name(self):
"""Test the references raise an informative error for bad instrument."""
with pytest.raises(KeyError) as kerr:
mm_norp.references('ace', 'sis')

assert str(kerr.value).find('ace') >= 0, \
"Unknown KeyError message: {:}".format(kerr.value)
return

0 comments on commit 9b8b48b

Please sign in to comment.