diff --git a/tests/helpers/test_initialize_mth5.py b/tests/helpers/test_initialize_mth5.py index b9ba42b0..ad5cc1f4 100644 --- a/tests/helpers/test_initialize_mth5.py +++ b/tests/helpers/test_initialize_mth5.py @@ -51,6 +51,33 @@ def tearDownClass(self): self.wd.joinpath("test.h5").unlink() + +class TestCompression(unittest.TestCase): + @classmethod + def setUpClass(self): + self.wd = Path().cwd() + + + def test_has_open_file(self): + self.m = initialize_mth5(self.wd.joinpath("test.h5"), "w") + self.assertIsInstance(self.m, MTH5) + + def test_validate_compression(self): + """ COMPRESSION = ["lzf", "gzip", "szip", None]""" + from mth5.helpers import COMPRESSION + from mth5.helpers import COMPRESSION_LEVELS + for compression_type in COMPRESSION: + for compression_level in COMPRESSION_LEVELS[compression_type]: + self.m = MTH5(compression=compression_type, compression_opts=compression_level) + self.m.open_mth5(self.wd.joinpath("test.h5"), mode="a") + self.m = initialize_mth5(self.wd.joinpath("test.h5"), "w") + self.assertIsInstance(self.m, MTH5) + self.m.close_mth5() + + @classmethod + def tearDownClass(self): + close_open_files() + self.wd.joinpath("test.h5").unlink() # ============================================================================= # Run # =============================================================================