@@ -283,72 +283,38 @@ def test_get_visits_empty_answer(self):
283
283
preload_content = True , timeout = None )
284
284
self .assertEqual (self .api .get_visits (mocked_id ).visits , [])
285
285
286
- def test_get_visits_bad_text_data (self ):
287
- """Test checks exception raising when client receives not a JSON answer """
286
+ def test_get_visits_bad_data (self ):
287
+ """Test checks exception raising when client receives answer with bad data shape """
288
288
mock_pool = MockPoolManager (self )
289
289
self .api .api_client .rest_client .pool_manager = mock_pool
290
- mocked_id = 'bad_text_data'
291
- mock_pool .expect_request ('GET' , TestFingerprintApi .get_visitors_path (visitor_id = mocked_id ),
292
- fields = [self .integration_info ], headers = self .request_headers ,
293
- preload_content = True , timeout = None )
294
- with self .assertRaises (ApiException ) as context :
295
- self .api .get_visits (mocked_id )
296
- self .assertEqual (context .exception .status , 200 )
297
- self .assertIsInstance (context .exception .reason , ValueError )
298
- self .assertEqual (context .exception .body , 'really bad data' )
299
-
300
- def test_get_visits_bad_json_data (self ):
301
- """Test checks exception raising when client receives a bad JSON answer"""
302
- mock_pool = MockPoolManager (self )
303
- self .api .api_client .rest_client .pool_manager = mock_pool
304
- mocked_id = 'bad_json_data'
305
- mock_pool .expect_request ('GET' , TestFingerprintApi .get_visitors_path (visitor_id = mocked_id ),
306
- fields = [self .integration_info ], headers = self .request_headers ,
307
- preload_content = True , timeout = None )
308
- with self .assertRaises (ApiException ) as context :
309
- self .api .get_visits (mocked_id )
310
- self .assertEqual (context .exception .status , 200 )
311
- self .assertIsInstance (context .exception .reason , ValueError )
312
- self .assertEqual (context .exception .body , '{}' )
313
-
314
- def test_init_with_us_region (self ):
290
+ test_cases = [
291
+ ('bad_text_data' , 'really bad data' ),
292
+ ('bad_json_data' , '{}' )
293
+ ]
294
+ for (mocked_id , raw_data ) in test_cases :
295
+ mock_pool .expect_request ('GET' , TestFingerprintApi .get_visitors_path (visitor_id = mocked_id ),
296
+ fields = [self .integration_info ], headers = self .request_headers ,
297
+ preload_content = True , timeout = None )
298
+ with self .assertRaises (ApiException ) as context :
299
+ self .api .get_visits (mocked_id )
300
+ self .assertEqual (context .exception .status , 200 )
301
+ self .assertIsInstance (context .exception .reason , ValueError )
302
+ self .assertEqual (context .exception .body , raw_data )
303
+
304
+ def test_init_with_region (self ):
315
305
"""Test that link for us region generates correct"""
316
- configuration = Configuration (api_key = API_KEY , region = "us" )
317
- self .api = FingerprintApi (configuration ) # noqa: E501
318
- mock_pool = MockPoolManager (self )
319
- self .api .api_client .rest_client .pool_manager = mock_pool
320
- mocked_id = 'empty_answer'
321
- mock_pool .expect_request ('GET' ,
322
- TestFingerprintApi .get_visitors_path (visitor_id = mocked_id , region = "us" ),
323
- fields = [self .integration_info ], headers = self .request_headers ,
324
- preload_content = True , timeout = None )
325
- self .assertEqual (self .api .get_visits (mocked_id ).visits , [])
326
-
327
- def test_init_with_eu_region (self ):
328
- """Test that link for eu region generates correct"""
329
- configuration = Configuration (api_key = API_KEY , region = "eu" )
330
- self .api = FingerprintApi (configuration ) # noqa: E501
331
- mock_pool = MockPoolManager (self )
332
- self .api .api_client .rest_client .pool_manager = mock_pool
333
- mocked_id = 'empty_answer'
334
- mock_pool .expect_request ('GET' ,
335
- TestFingerprintApi .get_visitors_path (visitor_id = mocked_id , region = "eu" ),
336
- fields = [self .integration_info ], headers = self .request_headers ,
337
- preload_content = True , timeout = None )
338
- self .assertEqual (self .api .get_visits (mocked_id ).visits , [])
339
-
340
- def test_init_with_ap_region (self ):
341
- """Test that link for ap region generates correct"""
342
- configuration = Configuration (api_key = API_KEY , region = "ap" )
343
- self .api = FingerprintApi (configuration ) # noqa: E501
344
- mock_pool = MockPoolManager (self )
345
- self .api .api_client .rest_client .pool_manager = mock_pool
346
- mocked_id = 'empty_answer'
347
- mock_pool .expect_request ('GET' ,
348
- TestFingerprintApi .get_visitors_path (visitor_id = mocked_id , region = "ap" ),
349
- fields = [self .integration_info ], headers = self .request_headers ,
350
- preload_content = True , timeout = None )
351
- self .assertEqual (self .api .get_visits (mocked_id ).visits , [])
306
+ regions_list = ["us" , "eu" , "ap" ]
307
+ for region in regions_list :
308
+ configuration = Configuration (api_key = API_KEY , region = region )
309
+ self .api = FingerprintApi (configuration ) # noqa: E501
310
+ mock_pool = MockPoolManager (self )
311
+ self .api .api_client .rest_client .pool_manager = mock_pool
312
+ mocked_id = 'empty_answer'
313
+ mock_pool .expect_request ('GET' ,
314
+ TestFingerprintApi .get_visitors_path (visitor_id = mocked_id , region = region ),
315
+ fields = [self .integration_info ], headers = self .request_headers ,
316
+ preload_content = True , timeout = None )
317
+ self .assertEqual (self .api .get_visits (mocked_id ).visits , [])
352
318
353
319
def test_delete_visitor_data (self ):
354
320
"""Test that delete visit method works"""
0 commit comments