Skip to content

Commit

Permalink
TST: add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jklenzing committed May 17, 2021
1 parent 8a42e3c commit 1c3d646
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pysatMissions/tests/test_instruments.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import datetime as dt
import numpy as np
import tempfile

import pytest
Expand Down Expand Up @@ -66,3 +68,21 @@ def teardown_class(self):
pysat.params.data['data_dirs'] = self.saved_path
self.tempdir.cleanup()
del self.inst_loc, self.saved_path, self.tempdir

# Custom package unit tests can be added here

@pytest.mark.parametrize("inst_dict", [x for x in instruments['download']])
@pytest.mark.parametrize("kwarg,output", [(None, 1), ('10s', 10)])
def test_inst_cadence(self, inst_dict, kwarg, output):
"""Test operation of cadence keyword, including default behavior"""

if kwarg:
self.test_inst = pysat.Instrument(
inst_module=inst_dict['inst_module'], cadence=kwarg)
else:
self.test_inst = pysat.Instrument(
inst_module=inst_dict['inst_module'])

self.test_inst.load(2019, 1)
cadence = np.diff(self.test_inst.data.index.to_pydatetime())
assert np.all(cadence == dt.timedelta(seconds=output))

0 comments on commit 1c3d646

Please sign in to comment.