Skip to content

Commit

Permalink
add tests for sentinel 2 L1 IDF converter
Browse files Browse the repository at this point in the history
  • Loading branch information
aperrin66 committed Feb 15, 2024
1 parent 2f158af commit fa141a0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/converters/test_idf_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,38 @@ def test_list_files_to_convert_error(self):
self.converter.list_files_to_convert('')


class Sentinel2IDFConverterTestCase(unittest.TestCase):
"""Tests for the Sentinel2IDFConverter class"""

def setUp(self):
self.converter = idf_converter.Sentinel2IDFConverter([])

def test_list_files_to_convert(self):
"""list_files_to_convert() should return all the files
contained in the "measurement" subdirectory of the dataset
directory
"""
contents = ['L1C_T33TVJ_A032566_20230601T095606']

with mock.patch('os.listdir', return_value=contents):
self.assertListEqual(
['dataset_dir/GRANULE/L1C_T33TVJ_A032566_20230601T095606'],
self.converter.list_files_to_convert('dataset_dir')
)

def test_list_files_to_convert_error(self):
"""list_files_to_convert() should raise a ConversionError when
the measurement directory is not present or is not a directory
"""
with mock.patch('os.listdir', side_effect=FileNotFoundError):
with self.assertRaises(converters_base.ConversionError):
self.converter.list_files_to_convert('')

with mock.patch('os.listdir', side_effect=NotADirectoryError):
with self.assertRaises(converters_base.ConversionError):
self.converter.list_files_to_convert('')


class Sentinel3SLSTRL2WSTIDFConverterTestCase(unittest.TestCase):
"""Tests for the Sentinel3SLSTRL2WSTIDFConverter class"""

Expand Down

0 comments on commit fa141a0

Please sign in to comment.