test_ifs_fits.py 831 Bytes
Newer Older
Xie Zhou's avatar
update    
Xie Zhou committed
1
import logging
Wei Shoulin's avatar
Wei Shoulin committed
2
import unittest
Xie Zhou's avatar
Xie Zhou committed
3
import os
Wei Shoulin's avatar
Wei Shoulin committed
4
5
6

from csst_dfs_api_local.ifs import FitsApi

Xie Zhou's avatar
update    
Xie Zhou committed
7
log = logging.getLogger('csst')
Wei Shoulin's avatar
Wei Shoulin committed
8
9
10
11
class IFSFitsTestCase(unittest.TestCase):

    def setUp(self):
        self.api = FitsApi()
Xie Zhou's avatar
Xie Zhou committed
12
        # self.api.scan2db()
Wei Shoulin's avatar
Wei Shoulin committed
13
14

    def test_find(self):
Xie Zhou's avatar
Xie Zhou committed
15
16
17
18
19
20
21
        path1 = self.api.find(obs_time=900, type='obs')
        log.info('find', path1)
        assert len(path1) > 0
        path2 = self.api.find(fits_id='CCD2_ObsTime_600_ObsNum_8.fits')
        log.info('find', path2)
        assert 'CCD2_ObsTime_600_ObsNum_8.fits' in path2

Xie Zhou's avatar
update    
Xie Zhou committed
22
23
    
    def test_read(self):
Xie Zhou's avatar
Xie Zhou committed
24
        file = self.api.read(fits_id='CCD2_ObsTime_600_ObsNum_8.fits')
Xie Zhou's avatar
update    
Xie Zhou committed
25
26
27
28
        log.info('read', str(type(file)))
        path = self.api.find(obs_time=900, type='obs')
        file = self.api.read(file_path=path)
        log.info('read', str(type(file)))