@@ -92,12 +92,11 @@ def test_odaapi(dispatcher_live_fixture):
9292
9393
9494@pytest .mark .odaapi
95- @pytest .mark .parametrize ("data_level" , ["realtime" , "ordinary" ])
9695@pytest .mark .parametrize ("roles" , ["integral-realtime" , "" ])
97- def test_odaapi_data (dispatcher_live_fixture , data_level , dispatcher_test_conf , roles ):
96+ def test_odaapi_data (dispatcher_live_fixture , dispatcher_test_conf , roles ):
9897 import oda_api .api
9998
100- params = {** default_parameters , 'data_level' : data_level }
99+ params = {** default_parameters , 'data_level' : "ordinary" }
101100 params ['token' ] = construct_token (roles .split ("," ), dispatcher_test_conf )
102101
103102 def get_products ():
@@ -108,58 +107,52 @@ def get_products():
108107 url = dispatcher_live_fixture ).get_product (** {** params , 'time_bin' : 0.05 })
109108
110109 return product_spiacs , product_spiacs_raw_bin
111-
112- if data_level == "realtime" and roles == "" :
113- with pytest .raises (Exception ) as excinfo :
114- get_products ()
115-
116- assert 'Unfortunately, your priviledges are not sufficient' in str (excinfo .value )
117- else :
118- product_spiacs , product_spiacs_raw_bin = get_products ()
119-
120- assert product_spiacs .spi_acs_lc_0_query .data_unit [1 ].header ['INSTRUME' ] == "SPI-ACS"
121- assert product_spiacs_raw_bin .spi_acs_lc_0_query .data_unit [1 ].header ['INSTRUME' ] == "SPI-ACS"
122-
123- data = np .array (product_spiacs .spi_acs_lc_0_query .data_unit [1 ].data )
124- data_raw_bin = np .array (product_spiacs_raw_bin .spi_acs_lc_0_query .data_unit [1 ].data )
125-
126- assert len (data ) > 100
127- assert len (data_raw_bin ) > 100
128-
129- assert np .std ((data ['RATE' ] - np .mean (data ['RATE' ]))/ data ['ERROR' ]) < 1.5
130- assert np .std ((data_raw_bin ['RATE' ] - np .mean (data_raw_bin ['RATE' ]))/ data_raw_bin ['ERROR' ]) < 1.5
131110
111+ product_spiacs , product_spiacs_raw_bin = get_products ()
132112
133- @pytest .mark .odaapi
134- def test_odaapi_data_coherence (dispatcher_live_fixture , dispatcher_test_conf ):
135- import oda_api .api
113+ assert product_spiacs .spi_acs_lc_0_query .data_unit [1 ].header ['INSTRUME' ] == "SPI-ACS"
114+ assert product_spiacs_raw_bin .spi_acs_lc_0_query .data_unit [1 ].header ['INSTRUME' ] == "SPI-ACS"
136115
137- params = {** default_parameters , 'time_bin' : 0.05 }
138- params ['token' ] = construct_token (["integral-realtime" ], dispatcher_test_conf )
139-
140- product_spiacs = oda_api .api .DispatcherAPI (
141- url = dispatcher_live_fixture ).get_product (** params )
142-
143- product_spiacs_rt = oda_api .api .DispatcherAPI (
144- url = dispatcher_live_fixture ).get_product (** {** params , 'data_level' : "realtime" })
145-
146116 data = np .array (product_spiacs .spi_acs_lc_0_query .data_unit [1 ].data )
147- t_ref = product_spiacs .spi_acs_lc_0_query .data_unit [1 ].header ['TIMEZERO' ]
148- t = data ['TIME' ] + t_ref
117+ data_raw_bin = np .array (product_spiacs_raw_bin .spi_acs_lc_0_query .data_unit [1 ].data )
149118
150- data_rt = np .array (product_spiacs_rt .spi_acs_lc_0_query .data_unit [1 ].data )
151- t_ref_rt = product_spiacs_rt .spi_acs_lc_0_query .data_unit [1 ].header ['TIMEZERO' ]
152- t_rt = data_rt ['TIME' ] + t_ref_rt
153-
154119 assert len (data ) > 100
155- assert len (data_rt ) > 100
156-
157- dt_s = (t - t_rt )
158- print ("dt min, max, mean, std" , dt_s .min (), dt_s .max (), dt_s .mean (), dt_s .std ())
159-
160- assert "next break in data in 46 hr" in product_spiacs_rt .spi_acs_lc_0_query .data_unit [1 ].header ['PROPHECY' ]
161- assert "166.134 81.107 109932.3 0.016 0.016 30.0" in product_spiacs_rt .spi_acs_lc_0_query .data_unit [1 ].header ['EPHS' ]
162- assert "166.134 81.107 109932.3 0.016 0.016 30.0" in product_spiacs .spi_acs_lc_0_query .data_unit [1 ].header ['EPHS' ]
120+ assert len (data_raw_bin ) > 100
121+
122+ assert np .std ((data ['RATE' ] - np .mean (data ['RATE' ]))/ data ['ERROR' ]) < 1.5
123+ assert np .std ((data_raw_bin ['RATE' ] - np .mean (data_raw_bin ['RATE' ]))/ data_raw_bin ['ERROR' ]) < 1.5
124+
125+
126+ # @pytest.mark.odaapi
127+ # def test_odaapi_data_coherence(dispatcher_live_fixture, dispatcher_test_conf):
128+ # import oda_api.api
129+ #
130+ # params = {**default_parameters, 'time_bin': 0.05}
131+ # params['token'] = construct_token(["integral-realtime"], dispatcher_test_conf)
132+ #
133+ # product_spiacs = oda_api.api.DispatcherAPI(
134+ # url=dispatcher_live_fixture).get_product(**params)
135+ #
136+ # product_spiacs_rt = oda_api.api.DispatcherAPI(
137+ # url=dispatcher_live_fixture).get_product(**{**params, 'data_level': "realtime"})
138+ #
139+ # data = np.array(product_spiacs.spi_acs_lc_0_query.data_unit[1].data)
140+ # t_ref = product_spiacs.spi_acs_lc_0_query.data_unit[1].header['TIMEZERO']
141+ # t = data['TIME'] + t_ref
142+ #
143+ # data_rt = np.array(product_spiacs_rt.spi_acs_lc_0_query.data_unit[1].data)
144+ # t_ref_rt = product_spiacs_rt.spi_acs_lc_0_query.data_unit[1].header['TIMEZERO']
145+ # t_rt = data_rt['TIME'] + t_ref_rt
146+ #
147+ # assert len(data) > 100
148+ # assert len(data_rt) > 100
149+ #
150+ # dt_s = (t - t_rt)
151+ # print("dt min, max, mean, std", dt_s.min(), dt_s.max(), dt_s.mean(), dt_s.std())
152+ #
153+ # assert "next break in data in 46 hr" in product_spiacs_rt.spi_acs_lc_0_query.data_unit[1].header['PROPHECY']
154+ # assert "166.134 81.107 109932.3 0.016 0.016 30.0" in product_spiacs_rt.spi_acs_lc_0_query.data_unit[1].header['EPHS']
155+ # assert "166.134 81.107 109932.3 0.016 0.016 30.0" in product_spiacs.spi_acs_lc_0_query.data_unit[1].header['EPHS']
163156
164157 # TODO: this verification will have to be completed
165158 # for offset in np.arange(-10, 10):
@@ -200,36 +193,36 @@ def test_request_too_large(dispatcher_live_fixture):
200193 assert any ('SPI-ACS backend refuses to process this request' in r for r in jdata ['exit_status' ].values ())
201194
202195
203- @pytest .mark .parametrize ("roles" , ["integral-realtime" , "" ])
204- def test_realtime (dispatcher_live_fixture , dispatcher_test_conf , roles ):
205- server = dispatcher_live_fixture
206-
207- logger .info ("constructed server: %s" , server )
208-
209- params = {
210- ** default_parameters ,
211- 'query_status' : 'new' ,
212- 'query_type' : 'Real' ,
213- 'data_level' : 'realtime '
214- }
215-
216- params ['token' ] = construct_token (roles .split ("," ), dispatcher_test_conf )
217-
218- c = requests .get (server + "/run_analysis" ,
219- params = params )
220-
221- logger .info ("content: %s" , c .text )
222- jdata = c .json ()
223- logger .info (json .dumps (jdata , indent = 4 , sort_keys = True ))
224- logger .info (jdata )
225-
226- print (jdata )
227-
228- if roles :
229- assert jdata ['job_status' ] == 'done'
230- assert c .status_code == 200
231- print (jdata ['products' ]['analysis_parameters' ])
232- else :
233- assert jdata ['job_status' ] == 'failed'
234- assert c .status_code == 403
196+ # @pytest.mark.parametrize("roles", ["integral-realtime", ""])
197+ # def test_realtime(dispatcher_live_fixture, dispatcher_test_conf, roles):
198+ # server = dispatcher_live_fixture
199+ #
200+ # logger.info("constructed server: %s", server)
201+ #
202+ # params = {
203+ # **default_parameters,
204+ # 'query_status': 'new',
205+ # 'query_type': 'Real',
206+ # 'data_level': 'ordinary '
207+ # }
208+ #
209+ # params['token'] = construct_token(roles.split(","), dispatcher_test_conf)
210+ #
211+ # c = requests.get(server + "/run_analysis",
212+ # params=params)
213+ #
214+ # logger.info("content: %s", c.text)
215+ # jdata = c.json()
216+ # logger.info(json.dumps(jdata, indent=4, sort_keys=True))
217+ # logger.info(jdata)
218+ #
219+ # print(jdata)
220+ #
221+ # if roles:
222+ # assert jdata['job_status'] == 'done'
223+ # assert c.status_code == 200
224+ # print(jdata['products']['analysis_parameters'])
225+ # else:
226+ # assert jdata['job_status'] == 'failed'
227+ # assert c.status_code == 403
235228
0 commit comments