Skip to content

Commit

Permalink
Add tests for pytroll#450
Browse files Browse the repository at this point in the history
  • Loading branch information
honnorat committed Oct 9, 2018
1 parent d5d0631 commit bf4aaa7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
7 changes: 4 additions & 3 deletions satpy/tests/reader_tests/test_hdf5_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,21 @@ def __init__(self, filename, filename_info, filetype_info, **kwargs):
if HDF5FileHandler is object:
raise ImportError("Base 'HDF5FileHandler' could not be "
"imported.")
filename = str(filename)
super(HDF5FileHandler, self).__init__(filename, filename_info, filetype_info)
self.file_content = self.get_test_content(filename, filename_info, filetype_info)
self.file_content.update(kwargs)

def get_test_content(self, filename, filename_info, filetype_info):
"""Mimic reader input file content
Args:
filename (str): input filename
filename (str): input filename
filename_info (dict): Dict of metadata pulled from filename
filetype_info (dict): Dict of metadata from the reader's yaml config for this file type
Returns: dict of file content with keys like:
- 'dataset'
- '/attr/global_attr'
- 'dataset/attr/global_attr'
Expand Down
13 changes: 12 additions & 1 deletion satpy/tests/test_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def tearDown(self):

def test_no_args(self):
"""Test no args provided.
This should check the local directory which should have no files.
"""
from satpy.readers import load_readers
Expand Down Expand Up @@ -243,6 +243,17 @@ def test_bad_reader_name_with_filenames(self):
'SVI01_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5',
])

def test_filenames_as_path(self):
"""Test with filenames specified as pathlib.Path"""
if sys.version_info < (3, 4):
return
from pathlib import Path
from satpy.readers import load_readers
ri = load_readers(filenames=[
Path('SVI01_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5'),
])
self.assertListEqual(list(ri.keys()), ['viirs_sdr'])

def test_filenames_as_dict(self):
"""Test loading readers where filenames are organized by reader"""
from satpy.readers import load_readers
Expand Down

0 comments on commit bf4aaa7

Please sign in to comment.