test_file.py 1.75 KB
Newer Older
BO ZHANG's avatar
BO ZHANG committed
1
2
3
4
5
6
7
8
9
10
"""
Identifier:     tests/test_file.py
Name:           test_file.py
Description:    test File class
Author:         Bo Zhang
Created:        2023-12-13
Modified-History:
    2023-12-13, Bo Zhang, add TestFile
    2023-12-15, Bo Zhang, add module header
"""
BO ZHANG's avatar
BO ZHANG committed
11
import unittest
12

BO ZHANG's avatar
BO ZHANG committed
13
from csst_common.cicd import File
BO ZHANG's avatar
BO ZHANG committed
14
15
16


class TestFile(unittest.TestCase):
BO ZHANG's avatar
BO ZHANG committed
17
    def test_file(self):
18
19
20
21
22
23
        file_path = (
            "/dfs_root/L0/MSC/SCI/61605/10160000072/MS/"
            "CSST_MSC_MS_SCIE_20270719043315_20270719043545_10160000072_07_L0_V01.fits"
        )
        file = File(file_path, new_dir="/pipeline/output")
        self.assertTrue(file.mo.groupdict() is not None)
BO ZHANG's avatar
BO ZHANG committed
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
        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"
            ),
        )