test_facility_level2producer.py 2.91 KB
Newer Older
Wei Shoulin's avatar
c3  
Wei Shoulin committed
1
2
import unittest

Wei Shoulin's avatar
brick    
Wei Shoulin committed
3
from csst_dfs_api.facility.level2producer import Level2ProducerApi
Wei Shoulin's avatar
c3  
Wei Shoulin committed
4

Wei Shoulin's avatar
brick    
Wei Shoulin committed
5
class FacilityLevel2ProducerTestCase(unittest.TestCase):
Wei Shoulin's avatar
c3  
Wei Shoulin committed
6
7

    def setUp(self):
Wei Shoulin's avatar
brick    
Wei Shoulin committed
8
        self.api = Level2ProducerApi()
Wei Shoulin's avatar
c3  
Wei Shoulin committed
9

Wei Shoulin's avatar
Wei Shoulin committed
10
11
12
13
14
15
16
17
    def test_register(self):
        rec = self.api.register(name='Test2', 
            gitlink='http://github.com/xxx/xxx',
            paramfiles='/opt/csst/param1.ini',
            priority = 3,
            pre_producers=[1,2] )
        print('register:', rec)

Wei Shoulin's avatar
c3  
Wei Shoulin committed
18
    def test_find(self):
Wei Shoulin's avatar
Wei Shoulin committed
19
        recs = self.api.find(key="Te")
Wei Shoulin's avatar
c3  
Wei Shoulin committed
20
21
22
        print('find:', recs)

    def test_get(self):
Wei Shoulin's avatar
Wei Shoulin committed
23
        rec = self.api.get(id=10)
Wei Shoulin's avatar
c3  
Wei Shoulin committed
24
25
        print('get:', rec)

Wei Shoulin's avatar
Wei Shoulin committed
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
    def test_find_nexts(self):
        recs = self.api.find_nexts(id=1)
        print('find_nexts:', recs)

    def test_find_start(self):
        recs = self.api.find_start(key="Te")
        print('find_start:', recs)

    def test_update(self):
        recs = self.api.update(
            id=2,
            name = "start2",
            gitlink = "http://github.com/xxx/xxx",
            paramfiles='/opt/csst/param1.ini',
            priority = 3,
            pre_producers=[1,3]
        )
        print('test_update:', recs)

    def test_delete(self):
        recs = self.api.delete(
            id=11
        )
        print('test_delete:', recs)

    def test_new_job(self):
        recs = self.api.new_job(
            dag = "start2-1-1-"
        )
        print('new_job:', recs)

    def test_get_job(self):
        recs = self.api.get_job(
            id = 2
        )
        print('get_job:', recs)     

    def test_update_job(self):
        recs = self.api.update_job(
            id = 2,
            dag = "222",
            status = 2
        )
        print('update_job:', recs) 

    def test_new_running(self):
        recs = self.api.new_running(
            job_id = 2,
            producer_id = 2,
            brick_id = 2,
            start_time = '2022-04-22 13:13:13'
        )
        print('new_running:', recs)

    def test_get_running(self):
        recs = self.api.get_running(
            id = 2
        )
        print('get_running:', recs)

    def test_update_running(self):
        recs = self.api.update_running(
            id = 3,
            job_id = 2,
            producer_id = 2,
            brick_id = 2,
            start_time = '2022-04-22 13:13:13',
            end_time = '2022-04-22 15:13:13',
            prc_status = 1,
            prc_result = 'OK'
        )
        print('update_running:', recs)
Wei Shoulin's avatar
c3  
Wei Shoulin committed
98

Wei Shoulin's avatar
Wei Shoulin committed
99
100
101
102
103
104
105
    def test_find_running(self):
        recs = self.api.find_running(
            job_id = 2,
            producer_id = 2,
            brick_id = 2,
            create_time = ('2022-04-22 10:13:13','2022-04-22 23:13:13')
        )
Wei Shoulin's avatar
graph    
Wei Shoulin committed
106
107
108
109
110
111
112
113
        print('find_running:', recs)

    def test_make_graph(self):
        graph_id_edges = self.api.make_graph(
            start_producer_id = 2,
            fig_path = 'graph.png'
        )
        print('graph_id_edges:', graph_id_edges)