Skip to content

Commit

Permalink
TST: Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoneback committed Feb 18, 2022
1 parent 0c8cae2 commit 3801e81
Showing 1 changed file with 16 additions and 37 deletions.
53 changes: 16 additions & 37 deletions pysatCDF/tests/test_cdf.py
Original file line number Diff line number Diff line change
@@ -1,67 +1,46 @@
import numpy as np

from nose.tools import assert_raises, raises
import nose.tools
import os

import pysatCDF

class TestBasics:

class TestBasics():
def setup(self):
"""Runs before every method to create a clean testing setup."""
# self.meta = pysat.Meta()
# self.testInst = pysat.Instrument('pysat', 'testing', tag='', clean_level='clean')

def teardown(self):
"""Runs after every method to clean up previous testing."""
# del self.testInst

def test_vefi_load(self):
import os
fname = os.path.join(pysatCDF.__path__[0],'tests', 'test_data',
"""Load VEFI file and perform basic data checks."""
fname = os.path.join(pysatCDF.__path__[0], 'tests', 'test_data',
'cnofs_vefi_bfield_1sec_20080601_v05.cdf')

with pysatCDF.CDF(fname) as cdf:
data = cdf.data

check = []
# basic checks on data that was loaded
check.append(data['B_flag'][0] == 0)
check.append(int(data['altitude'][0]) == 694)
check.append(data['year'][0] == 2008)

assert np.all(check)
# Basic checks on data that was loaded
assert data['B_flag'][0] == 0
assert int(data['altitude'][0]) == 694
assert data['year'][0] == 2008

return

def test_vefi_load_and_chameleon_data_access(self):
import os
fname = os.path.join(pysatCDF.__path__[0],'tests', 'test_data',
"""Load VEFI file and utilize spacepy like access."""
fname = os.path.join(pysatCDF.__path__[0], 'tests', 'test_data',
'cnofs_vefi_bfield_1sec_20080601_v05.cdf')

with pysatCDF.CDF(fname) as cdf:
data = cdf.data
# check on spacepy CDF attribute access mechanism
# Check on spacepy CDF attribute access mechanism
assert (cdf['year'].attrs['FILLVAL'] == 65535)

# basic checks on spacepy CDF data access
# Basic checks on spacepy CDF data access
assert (cdf['B_flag'][...][0] == 0)
assert (int(cdf['altitude'][...][0]) == 694)
assert (cdf['year'][...][0] == 2008)

def test_vefi_pysat_load(self):
import os
import pysat

fname = os.path.join(pysatCDF.__path__[0],'tests', 'test_data',
'cnofs_vefi_bfield_1sec_20080601_v05.cdf')
pysat.params['data_dirs'] = os.path.join(pysatCDF.__path__[0], 'tests',
'test_data')
vefi = pysat.Instrument(platform='cnofs', name='vefi',
tag='dc_b', manual_org=True)
vefi.load(fname='cnofs_vefi_bfield_1sec_20080601_v05.cdf')

check = []
# basic checks on data that was loaded
check.append(vefi[0, 'B_flag'] == 0)
check.append(int(vefi[0, 'altitude']) == 694)
check.append(vefi[0, 'year'] == 2008)

assert np.all(check)
return

0 comments on commit 3801e81

Please sign in to comment.