test_plan.py 1.55 KB
Newer Older
Wei Shoulin's avatar
plan  
Wei Shoulin committed
1
2
3
4
import unittest
import time
from csst_dfs_client import plan

Wei Shoulin's avatar
Wei Shoulin committed
5
class PlanTestCase(unittest.TestCase):
Wei Shoulin's avatar
plan  
Wei Shoulin committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

    def setUp(self):
        pass

    def test_find(self):
        start_time = time.time()
        result = plan.find(obsid = "101000003",
                        obstime = ("2021-08-30 00:00:00", "2024-12-30 23:59:59"))
        if result.success:
            print(f"time used: {time.time() - start_time} 's, count: {result['total_count']}")
        else:
            print(f"time used: {time.time() - start_time} 's, error message: " + result.message)

        self.assertEqual(result.code, 200, "error code: " + str(result.code))
        self.assertIsNotNone(result.data, "error message: " + result.message)

    def test_find_by_opid(self):
        result = plan.find_by_opid(opid = "101000000373")
        print(result)
        self.assertEqual(result.code, 200, "error code: " + str(result.code) + ", message: " + result.message)
        self.assertIsNotNone(result.data, "error message: " + result.message)

    def test_write(self):
        file_path = "/Users/wsl/temp/csst/import/plan_test.json"
        result = plan.write_file(local_file = file_path)
        print(result)
        self.assertEqual(result.code, 200, "error code: " + str(result.code) + ", message: " + result.message)

    def test_new(self):
        data = {'opid':'1', 'backend':'IFS', 'obstype': 'SCIE', 'obsid': '1'}
        result = plan.new(data = data)
        print(result)
        self.assertEqual(result.code, 200, "error code: " + str(result.code) + ", message: " + result.message)