diff --git a/csst_common/file.py b/csst_common/file.py index 5fa0e5623c359f78b48719dbfe1687f41987cb1f..0197136e376fb07404776b7d9b620294cd35ef73 100644 --- a/csst_common/file.py +++ b/csst_common/file.py @@ -86,7 +86,7 @@ class File: f"{self.obs_id if obs_id is None else str(obs_id)}_" f"{self.detector if detector is None else str(detector)}_" f"L{self.level if level is None else str(level)}_" - f"V{self.version if version is None else str(version)}" + f"V{self.version if version is None else str(version).zfill(2)}" f"{self.ext if ext is None else str(ext)}", ) diff --git a/tests/test_file.py b/tests/test_file.py index 97fed43f890d7f737dedf202f39c2ee39db301c9..4c051f82b1a0b955e23a865277782777c17fdf32 100644 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -21,3 +21,41 @@ class TestFile(unittest.TestCase): ) file = File(file_path, new_dir="/pipeline/output") self.assertTrue(file.mo.groupdict() is not None) + self.assertEqual( + file.derive0(), + ( + "/pipeline/output/" + "CSST_MSC_MS_SCIE_20270719043315_20270719043545_10160000072_07_L0_V01.fits" + ), + ) + + self.assertEqual( + file.derive1(), + ( + "/pipeline/output/" + "CSST_MSC_MS_SCIE_20270719043315_20270719043545_10160000072_07_L1_V01.fits" + ), + ) + self.assertEqual( + file.derive1(version=2), + ( + "/pipeline/output/" + "CSST_MSC_MS_SCIE_20270719043315_20270719043545_10160000072_07_L1_V02.fits" + ), + ) + + self.assertEqual( + file.derive2(), + ( + "/pipeline/output/" + "CSST_MSC_MS_SCIE_20270719043315_20270719043545_10160000072_07_L2_V01.fits" + ), + ) + + self.assertEqual( + file.derive2(ext=".cat"), + ( + "/pipeline/output/" + "CSST_MSC_MS_SCIE_20270719043315_20270719043545_10160000072_07_L2_V01.cat" + ), + )