test_facility_level1.py 1.88 KB
Newer Older
Wei Shoulin's avatar
c3  
Wei Shoulin committed
1
2
3
4
import os
import unittest
from astropy.io import fits

Wei Shoulin's avatar
Wei Shoulin committed
5
from csst_dfs_api.facility.level1 import Level1DataApi
Wei Shoulin's avatar
c3  
Wei Shoulin committed
6

Wei Shoulin's avatar
Wei Shoulin committed
7
class Level1DataTestCase(unittest.TestCase):
Wei Shoulin's avatar
c3  
Wei Shoulin committed
8
9
10
11
12

    def setUp(self):
        self.api = Level1DataApi()

    def test_find(self):
Wei Shoulin's avatar
Wei Shoulin committed
13
        recs = self.api.find(
Wei Shoulin's avatar
C9    
Wei Shoulin committed
14
15
16
            level0_id='10000010101',
            module_id = "MSC",
            create_time = ("2024-01-01 11:12:13","2024-06-08 11:12:13"))
Wei Shoulin's avatar
c3  
Wei Shoulin committed
17
18
        print('find:', recs)

Wei Shoulin's avatar
Wei Shoulin committed
19
20
    def test_find_by_ids(self):
        recs = self.api.find_by_ids(
Wei Shoulin's avatar
C9    
Wei Shoulin committed
21
22
            module_id = "MSC",
            ids=[16]
Wei Shoulin's avatar
Wei Shoulin committed
23
24
25
        )
        print('find_by_ids:', recs)

Wei Shoulin's avatar
C9    
Wei Shoulin committed
26
27
28
29
30
31
32
33
34
35
36
37
38
    def test_find_by_brick_ids(self):
        recs = self.api.find_by_brick_ids(
            brick_ids=[1,2,3,4]
        )
        print('find_by_brick_ids:', recs)

    def test_sls_find_by_qc1_status(self):
        recs = self.api.sls_find_by_qc1_status(
            qc1_status = 1,
            limit = 1
        )
        print('sls_find_by_qc1_status:', recs)

Wei Shoulin's avatar
c3  
Wei Shoulin committed
39
40
41
42
43
44
45
46
47
48
49
50
51
    def test_get(self):
        rec = self.api.get(id = 2)
        print('get:', rec)

    def test_update_proc_status(self):
        rec = self.api.update_proc_status(id = 2, status = 4)
        print('update_proc_status:', rec)

    def test_update_qc1_status(self):
        rec = self.api.update_qc1_status(id = 2, status = 7)
        print('update_qc1_status:', rec)

    def test_write(self):
Wei Shoulin's avatar
Wei Shoulin committed
52
        rec = self.api.write(
Wei Shoulin's avatar
Wei Shoulin committed
53
            level0_id = '10000010101', 
Wei Shoulin's avatar
C9    
Wei Shoulin committed
54
            file_type = "SCIE",
Wei Shoulin's avatar
c3  
Wei Shoulin committed
55
            prc_status = 3,
Wei Shoulin's avatar
Wei Shoulin committed
56
            prc_time = '2021-10-22 11:12:13',
Wei Shoulin's avatar
Wei Shoulin committed
57
58
            filename = "CSST_MSC_MS_SCI_20270810142128_20270810142358_100000101_20_img_L1.fits",
            file_path = "/opt/temp/csst/CSST_MSC_MS_SCI_20270810142128_20270810142358_100000101_20_img_L1.fits",
Wei Shoulin's avatar
Wei Shoulin committed
59
            pipeline_id = "P1",
Wei Shoulin's avatar
C9    
Wei Shoulin committed
60
61
62
            build_id = 123,
            refs = [('dark', '1'), ('bias', '2'), ('flat', '3')]
        )
Wei Shoulin's avatar
c3  
Wei Shoulin committed
63
        print('write:', rec)