Skip to content

Commit d80bbe4

Browse files
committed
test(codacy): Pay heed to codacy-bot
1 parent ba52836 commit d80bbe4

1 file changed

Lines changed: 68 additions & 33 deletions

File tree

test/unit/test_discovery_v1.py

Lines changed: 68 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ def setUp(cls):
5757
responses.add(
5858
responses.POST, url=iam_url, body=json.dumps(iam_token_response), status=200)
5959

60+
@classmethod
6061
@responses.activate
61-
def test_environments(self):
62+
def test_environments(cls):
6263
discovery_url = urljoin(base_discovery_url, 'environments')
6364
discovery_response_body = """{
6465
"environments": [
@@ -104,8 +105,9 @@ def test_environments(self):
104105
assert responses.calls[0].response.text == discovery_response_body
105106
assert len(responses.calls) == 1
106107

108+
@classmethod
107109
@responses.activate
108-
def test_get_environment(self):
110+
def test_get_environment(cls):
109111
discovery_url = urljoin(base_discovery_url, 'environments/envid')
110112
responses.add(responses.GET, discovery_url,
111113
body="{\"resulting_key\": true}", status=200,
@@ -120,8 +122,9 @@ def test_get_environment(self):
120122
assert len(responses.calls) == 1
121123

122124

125+
@classmethod
123126
@responses.activate
124-
def test_create_environment(self):
127+
def test_create_environment(cls):
125128

126129
discovery_url = urljoin(base_discovery_url, 'environments')
127130
responses.add(responses.POST, discovery_url,
@@ -136,8 +139,9 @@ def test_create_environment(self):
136139
assert len(responses.calls) == 1
137140

138141

142+
@classmethod
139143
@responses.activate
140-
def test_update_environment(self):
144+
def test_update_environment(cls):
141145
discovery_url = urljoin(base_discovery_url, 'environments/envid')
142146
responses.add(responses.PUT, discovery_url,
143147
body="{\"resulting_key\": true}", status=200,
@@ -150,8 +154,9 @@ def test_update_environment(self):
150154
assert len(responses.calls) == 1
151155

152156

157+
@classmethod
153158
@responses.activate
154-
def test_delete_environment(self):
159+
def test_delete_environment(cls):
155160
discovery_url = urljoin(base_discovery_url, 'environments/envid')
156161
responses.add(responses.DELETE, discovery_url,
157162
body="{\"resulting_key\": true}", status=200,
@@ -164,8 +169,9 @@ def test_delete_environment(self):
164169
assert len(responses.calls) == 1
165170

166171

172+
@classmethod
167173
@responses.activate
168-
def test_collections(self):
174+
def test_collections(cls):
169175
discovery_url = urljoin(base_discovery_url,
170176
'environments/envid/collections')
171177

@@ -186,8 +192,9 @@ def test_collections(self):
186192
assert len(responses.calls) == 1
187193

188194

195+
@classmethod
189196
@responses.activate
190-
def test_collection(self):
197+
def test_collection(cls):
191198
discovery_url = urljoin(base_discovery_url,
192199
'environments/envid/collections/collid')
193200

@@ -248,8 +255,9 @@ def test_collection(self):
248255
collection_id='collid')
249256
assert len(responses.calls) == 5
250257

258+
@classmethod
251259
@responses.activate
252-
def test_federated_query(self):
260+
def test_federated_query(cls):
253261
discovery_url = urljoin(base_discovery_url,
254262
'environments/envid/query')
255263

@@ -268,8 +276,9 @@ def test_federated_query(self):
268276
assert called_url.path == test_url.path
269277
assert len(responses.calls) == 1
270278

279+
@classmethod
271280
@responses.activate
272-
def test_federated_query_2(self):
281+
def test_federated_query_2(cls):
273282
discovery_url = urljoin(base_discovery_url,
274283
'environments/envid/query')
275284

@@ -289,8 +298,9 @@ def test_federated_query_2(self):
289298
assert called_url.path == test_url.path
290299
assert len(responses.calls) == 1
291300

301+
@classmethod
292302
@responses.activate
293-
def test_federated_query_notices(self):
303+
def test_federated_query_notices(cls):
294304
discovery_url = urljoin(base_discovery_url,
295305
'environments/envid/notices')
296306

@@ -307,8 +317,9 @@ def test_federated_query_notices(self):
307317
assert called_url.path == test_url.path
308318
assert len(responses.calls) == 1
309319

320+
@classmethod
310321
@responses.activate
311-
def test_query(self):
322+
def test_query(cls):
312323
discovery_url = urljoin(base_discovery_url,
313324
'environments/envid/collections/collid/query')
314325

@@ -333,8 +344,9 @@ def test_query(self):
333344
assert called_url.path == test_url.path
334345
assert len(responses.calls) == 1
335346

347+
@classmethod
336348
@responses.activate
337-
def test_query_2(self):
349+
def test_query_2(cls):
338350
discovery_url = urljoin(base_discovery_url,
339351
'environments/envid/collections/collid/query')
340352

@@ -361,8 +373,9 @@ def test_query_2(self):
361373
assert called_url.path == test_url.path
362374
assert len(responses.calls) == 1
363375

376+
@classmethod
364377
@responses.activate
365-
def test_query_relations(self):
378+
def test_query_relations(cls):
366379
discovery_url = urljoin(
367380
base_discovery_url,
368381
'environments/envid/collections/collid/query_relations')
@@ -385,8 +398,9 @@ def test_query_relations(self):
385398
assert len(responses.calls) == 1
386399

387400

401+
@classmethod
388402
@responses.activate
389-
def test_query_entities(self):
403+
def test_query_entities(cls):
390404
discovery_url = urljoin(
391405
base_discovery_url,
392406
'environments/envid/collections/collid/query_entities')
@@ -408,8 +422,9 @@ def test_query_entities(self):
408422
assert called_url.path == test_url.path
409423
assert len(responses.calls) == 1
410424

425+
@classmethod
411426
@responses.activate
412-
def test_query_notices(self):
427+
def test_query_notices(cls):
413428
discovery_url = urljoin(
414429
base_discovery_url,
415430
'environments/envid/collections/collid/notices')
@@ -431,8 +446,10 @@ def test_query_notices(self):
431446
assert called_url.path == test_url.path
432447
assert len(responses.calls) == 1
433448

449+
450+
@classmethod
434451
@responses.activate
435-
def test_configs(self):
452+
def test_configs(cls):
436453
discovery_url = urljoin(base_discovery_url,
437454
'environments/envid/configurations')
438455
discovery_config_id = urljoin(base_discovery_url,
@@ -490,8 +507,9 @@ def test_configs(self):
490507
assert len(responses.calls) == 7
491508

492509

510+
@classmethod
493511
@responses.activate
494-
def test_document(self):
512+
def test_document(cls):
495513
discovery_url = urljoin(base_discovery_url,
496514
'environments/envid/preview')
497515
config_url = urljoin(base_discovery_url,
@@ -616,8 +634,9 @@ def test_document(self):
616634
assert len(responses.calls) == 10
617635

618636

637+
@classmethod
619638
@responses.activate
620-
def test_delete_all_training_data(self):
639+
def test_delete_all_training_data(cls):
621640
training_endpoint = '/v1/environments/{0}/collections/{1}/training_data'
622641
endpoint = training_endpoint.format(environment_id, collection_id)
623642
url = '{0}{1}'.format(base_url, endpoint)
@@ -630,8 +649,9 @@ def test_delete_all_training_data(self):
630649
assert response is None
631650

632651

652+
@classmethod
633653
@responses.activate
634-
def test_list_training_data(self):
654+
def test_list_training_data(cls):
635655
training_endpoint = '/v1/environments/{0}/collections/{1}/training_data'
636656
endpoint = training_endpoint.format(environment_id, collection_id)
637657
url = '{0}{1}'.format(base_url, endpoint)
@@ -670,8 +690,9 @@ def test_list_training_data(self):
670690
TrainingDataSet._from_dict(response)
671691

672692

693+
@classmethod
673694
@responses.activate
674-
def test_add_training_data(self):
695+
def test_add_training_data(cls):
675696
training_endpoint = '/v1/environments/{0}/collections/{1}/training_data'
676697
endpoint = training_endpoint.format(environment_id, collection_id)
677698
url = '{0}{1}'.format(base_url, endpoint)
@@ -721,8 +742,9 @@ def test_add_training_data(self):
721742
TrainingQuery._from_dict(response)
722743

723744

745+
@classmethod
724746
@responses.activate
725-
def test_delete_training_data(self):
747+
def test_delete_training_data(cls):
726748
training_endpoint = '/v1/environments/{0}/collections/{1}/training_data/{2}'
727749
query_id = 'queryid'
728750
endpoint = training_endpoint.format(
@@ -740,8 +762,9 @@ def test_delete_training_data(self):
740762
assert response is None
741763

742764

765+
@classmethod
743766
@responses.activate
744-
def test_get_training_data(self):
767+
def test_get_training_data(cls):
745768
training_endpoint = '/v1/environments/{0}/collections/{1}/training_data/{2}'
746769
query_id = 'queryid'
747770
endpoint = training_endpoint.format(
@@ -775,8 +798,9 @@ def test_get_training_data(self):
775798
TrainingQuery._from_dict(response)
776799

777800

801+
@classmethod
778802
@responses.activate
779-
def test_create_training_example(self):
803+
def test_create_training_example(cls):
780804
examples_endpoint = '/v1/environments/{0}/collections/{1}/training_data' + \
781805
'/{2}/examples'
782806
query_id = 'queryid'
@@ -813,8 +837,9 @@ def test_create_training_example(self):
813837
TrainingExample._from_dict(response)
814838

815839

840+
@classmethod
816841
@responses.activate
817-
def test_delete_training_example(self):
842+
def test_delete_training_example(cls):
818843
examples_endpoint = '/v1/environments/{0}/collections/{1}/training_data' + \
819844
'/{2}/examples/{3}'
820845
query_id = 'queryid'
@@ -836,8 +861,9 @@ def test_delete_training_example(self):
836861
assert response is None
837862

838863

864+
@classmethod
839865
@responses.activate
840-
def test_get_training_example(self):
866+
def test_get_training_example(cls):
841867
examples_endpoint = '/v1/environments/{0}/collections/{1}/training_data' + \
842868
'/{2}/examples/{3}'
843869
query_id = 'queryid'
@@ -870,8 +896,9 @@ def test_get_training_example(self):
870896
TrainingExample._from_dict(response)
871897

872898

899+
@classmethod
873900
@responses.activate
874-
def test_update_training_example(self):
901+
def test_update_training_example(cls):
875902
examples_endpoint = '/v1/environments/{0}/collections/{1}/training_data' + \
876903
'/{2}/examples/{3}'
877904
query_id = 'queryid'
@@ -909,8 +936,9 @@ def test_update_training_example(self):
909936
# Verify that response can be converted to a TrainingExample
910937
TrainingExample._from_dict(response)
911938

939+
@classmethod
912940
@responses.activate
913-
def test_expansions(self):
941+
def test_expansions(cls):
914942
url = 'https://gateway.watsonplatform.net/discovery/api/v1/environments/envid/collections/colid/expansions'
915943
responses.add(
916944
responses.GET,
@@ -944,8 +972,9 @@ def test_expansions(self):
944972

945973
assert len(responses.calls) == 3
946974

975+
@classmethod
947976
@responses.activate
948-
def test_delete_user_data(self):
977+
def test_delete_user_data(cls):
949978
url = 'https://gateway.watsonplatform.net/discovery/api/v1/user_data'
950979
responses.add(
951980
responses.DELETE,
@@ -960,8 +989,9 @@ def test_delete_user_data(self):
960989
assert response is None
961990
assert len(responses.calls) == 1
962991

992+
@classmethod
963993
@responses.activate
964-
def test_credentials(self):
994+
def test_credentials(cls):
965995
discovery_credentials_url = urljoin(base_discovery_url, 'environments/envid/credentials')
966996

967997
results = {'credential_id': 'e68305ce-29f3-48ea-b829-06653ca0fdef',
@@ -1011,8 +1041,9 @@ def test_credentials(self):
10111041
discovery.delete_credentials(environment_id='envid', credential_id='credential_id')
10121042
assert len(responses.calls) == 10
10131043

1044+
@classmethod
10141045
@responses.activate
1015-
def test_events_and_feedback(self):
1046+
def test_events_and_feedback(cls):
10161047
discovery_event_url = urljoin(base_discovery_url, 'events')
10171048
discovery_metrics_event_rate_url = urljoin(base_discovery_url, 'metrics/event_rate')
10181049
discovery_metrics_query_url = urljoin(base_discovery_url, 'metrics/number_of_queries')
@@ -1170,8 +1201,9 @@ def test_events_and_feedback(self):
11701201

11711202
assert len(responses.calls) == 14
11721203

1204+
@classmethod
11731205
@responses.activate
1174-
def test_tokenization_dictionary(self):
1206+
def test_tokenization_dictionary(cls):
11751207
url = 'https://gateway.watsonplatform.net/discovery/api/v1/environments/envid/collections/colid/word_lists/tokenization_dictionary?version=2017-11-07'
11761208
responses.add(
11771209
responses.POST,
@@ -1212,8 +1244,9 @@ def test_tokenization_dictionary(self):
12121244

12131245
assert len(responses.calls) == 3
12141246

1247+
@classmethod
12151248
@responses.activate
1216-
def test_stopword_operations(self):
1249+
def test_stopword_operations(cls):
12171250
url = 'https://gateway.watsonplatform.net/discovery/api/v1/environments/envid/collections/colid/word_lists/stopwords?version=2017-11-07'
12181251
responses.add(
12191252
responses.POST,
@@ -1247,8 +1280,10 @@ def test_stopword_operations(self):
12471280

12481281
assert len(responses.calls) == 3
12491282

1283+
1284+
@classmethod
12501285
@responses.activate
1251-
def test_gateway_configuration(self):
1286+
def test_gateway_configuration(cls):
12521287
discovery_gateway_url = urljoin(base_discovery_url, 'environments/envid/gateways')
12531288

12541289
gateway_details = {

0 commit comments

Comments
 (0)