Skip to content

Commit 889f84f

Browse files
author
Martin Kudlej
committed
small pylint fixes
1 parent f1786ce commit 889f84f

File tree

3 files changed

+126
-112
lines changed

3 files changed

+126
-112
lines changed

tests/integration/conftest.py

Lines changed: 91 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def apicast_http_client(application, proxy, ssl_verify):
121121
@pytest.fixture(scope="module")
122122
def service_params():
123123
suffix = get_suffix()
124-
return dict(name=f"test-{suffix}")
124+
return {"name": f"test-{suffix}"}
125125

126126

127127
@pytest.fixture(scope="module")
@@ -135,14 +135,14 @@ def service(service_params, api) -> Service:
135135
def account_params():
136136
suffix = get_suffix()
137137
name = f"testacc{suffix}"
138-
return dict(
139-
name=name,
140-
username=name,
141-
org_name=name,
142-
monthly_billing_enabled=False,
143-
monthly_charging_enabled=False,
144-
email=f"{name}@name.none",
145-
)
138+
return {
139+
"name": name,
140+
"username": name,
141+
"org_name": name,
142+
"monthly_billing_enabled": False,
143+
"monthly_charging_enabled": False,
144+
"email": f"{name}@name.none",
145+
}
146146

147147

148148
@pytest.fixture(scope="module")
@@ -161,12 +161,12 @@ def acc_user(account):
161161
@pytest.fixture(scope="module")
162162
def acc_user2_params(account, acc_user):
163163
name = acc_user["username"] + "2"
164-
return dict(
165-
username=name,
166-
email=f"{name}@name.none",
167-
role="member",
168-
account_name=account["name"],
169-
)
164+
return {
165+
"username": name,
166+
"email": f"{name}@name.none",
167+
"role": "member",
168+
"account_name": account["name"],
169+
}
170170

171171

172172
@pytest.fixture(scope="module")
@@ -177,12 +177,12 @@ def acc_user2(account, acc_user, acc_user2_params):
177177
@pytest.fixture(scope="module")
178178
def application_plan_params(service) -> dict:
179179
suffix = get_suffix()
180-
return dict(
181-
name=f"test-{suffix}",
182-
setup_fee="1.00",
183-
state_event="publish",
184-
cost_per_month="3.00",
185-
)
180+
return {
181+
"name": f"test-{suffix}",
182+
"setup_fee": "1.00",
183+
"state_event": "publish",
184+
"cost_per_month": "3.00",
185+
}
186186

187187

188188
@pytest.fixture(scope="module")
@@ -196,13 +196,13 @@ def application_plan(api, service, application_plan_params) -> ApplicationPlan:
196196
def application_params(application_plan, service, account):
197197
suffix = get_suffix()
198198
name = f"test-{suffix}"
199-
return dict(
200-
name=name,
201-
description=name,
202-
plan_id=application_plan["id"],
203-
service_id=service["id"],
204-
account_id=account["id"],
205-
)
199+
return {
200+
"name": name,
201+
"description": name,
202+
"plan_id": application_plan["id"],
203+
"service_id": service["id"],
204+
"account_id": account["id"],
205+
}
206206

207207

208208
@pytest.fixture(scope="module")
@@ -270,15 +270,15 @@ def metric_params(service):
270270
suffix = get_suffix()
271271
friendly_name = f"test-metric-{suffix}"
272272
name = f"{friendly_name}".replace("-", "_")
273-
return dict(friendly_name=friendly_name, system_name=name, unit="count")
273+
return {"friendly_name": friendly_name, "system_name": name, "unit": "count"}
274274

275275

276276
@pytest.fixture(scope="module")
277277
def backend_metric_params():
278278
suffix = get_suffix()
279279
friendly_name = f"test-metric-{suffix}"
280280
name = f"{friendly_name}".replace("-", "")
281-
return dict(friendly_name=friendly_name, system_name=name, unit="count")
281+
return {"friendly_name": friendly_name, "system_name": name, "unit": "count"}
282282

283283

284284
@pytest.fixture(scope="module")
@@ -310,7 +310,7 @@ def method_params():
310310
suffix = get_suffix()
311311
friendly_name = f"test-method-{suffix}"
312312
system_name = f"{friendly_name}".replace("-", "_")
313-
return dict(friendly_name=friendly_name, system_name=system_name)
313+
return {"friendly_name": friendly_name, "system_name": system_name}
314314

315315

316316
# 'friendly_name' is id in CRD for methods
@@ -347,7 +347,12 @@ def mapping_rule_params(service):
347347
Fixture for getting paramteres for mapping rule for product/service.
348348
"""
349349
hits_metric = service.metrics.read_by_name("hits")
350-
return dict(http_method="GET", pattern="/get", metric_id=hits_metric["id"], delta=1)
350+
return {
351+
"http_method": "GET",
352+
"pattern": "/get",
353+
"metric_id": hits_metric["id"],
354+
"delta": 1,
355+
}
351356

352357

353358
@pytest.fixture(scope="module")
@@ -356,7 +361,12 @@ def backend_mapping_rule_params(backend, backend_metric):
356361
Fixture for getting paramteres for mapping rule for backend.
357362
"""
358363
back = backend_metric["id"]
359-
return dict(http_method="GET", pattern="/anything/get/ida", metric_id=back, delta=1)
364+
return {
365+
"http_method": "GET",
366+
"pattern": "/anything/get/ida",
367+
"metric_id": back,
368+
"delta": 1,
369+
}
360370

361371

362372
@pytest.fixture(scope="module")
@@ -414,13 +424,13 @@ def create_mapping_rule(service):
414424
rules = []
415425

416426
def _create(metric, http_method, path):
417-
params = dict(
418-
service_id=service["id"],
419-
http_method=http_method,
420-
pattern=f"/anything{path}",
421-
delta=1,
422-
metric_id=metric["id"],
423-
)
427+
params = {
428+
"service_id": service["id"],
429+
"http_method": http_method,
430+
"pattern": f"/anything{path}",
431+
"delta": 1,
432+
"metric_id": metric["id"],
433+
}
424434
rule = service.mapping_rules.create(params=params)
425435
rules.append(rule)
426436
return rule
@@ -441,13 +451,13 @@ def create_backend_mapping_rule(backend):
441451
rules = []
442452

443453
def _create(backend_metric, http_method, path):
444-
params = dict(
445-
backend_id=backend["id"],
446-
http_method=http_method,
447-
pattern=f"/anything{path}",
448-
delta=1,
449-
metric_id=backend_metric["id"],
450-
)
454+
params = {
455+
"backend_id": backend["id"],
456+
"http_method": http_method,
457+
"pattern": f"/anything{path}",
458+
"delta": 1,
459+
"metric_id": backend_metric["id"],
460+
}
451461
rule = backend.mapping_rules.create(params=params)
452462
rules.append(rule)
453463
return rule
@@ -465,9 +475,11 @@ def backend_params(api_backend):
465475
Fixture for getting backend parameters.
466476
"""
467477
suffix = get_suffix()
468-
return dict(
469-
name=f"test-backend-{suffix}", private_endpoint=api_backend, description="111"
470-
)
478+
return {
479+
"name": f"test-backend-{suffix}",
480+
"private_endpoint": api_backend,
481+
"description": "111",
482+
}
471483

472484

473485
@pytest.fixture(scope="module")
@@ -505,12 +517,12 @@ def tenant_params():
505517
"""
506518
Params for custom tenant
507519
"""
508-
return dict(
509-
username=f"tenant{get_suffix()}",
510-
admin_password="123456",
511-
email=f"e{get_suffix()}@invalid.invalid",
512-
org_name="org",
513-
)
520+
return {
521+
"username": f"tenant{get_suffix()}",
522+
"admin_password": "123456",
523+
"email": f"e{get_suffix()}@invalid.invalid",
524+
"org_name": "org",
525+
}
514526

515527

516528
@pytest.fixture(scope="module")
@@ -525,7 +537,7 @@ def active_docs_params(active_docs_body):
525537
suffix = get_suffix()
526538
name = f"test-{suffix}"
527539
des = f"description-{suffix}"
528-
return dict(name=name, body=active_docs_body, description=des)
540+
return {"name": name, "body": active_docs_body, "description": des}
529541

530542

531543
@pytest.fixture(scope="module")
@@ -544,17 +556,17 @@ def active_doc(api, service, active_docs_params) -> ActiveDoc:
544556
def openapi_params(active_docs_body):
545557
suffix = get_suffix()
546558
name = f"test-{suffix}"
547-
params = dict(
548-
name=name,
549-
productionPublicBaseURL="http://productionPublicBaseURL",
550-
stagingPublicBaseURL="http://stagingPublicBaseURL",
551-
productSystemName="PrOdUcTsYsTeMnAmE",
552-
privateBaseURL="http://privateBaseURL",
553-
prefixMatching=True,
554-
privateAPIHostHeader="privateAPIHostHeader",
555-
privateAPISecretToken="privateAPISecretToken",
556-
body=active_docs_body,
557-
)
559+
params = {
560+
"name": name,
561+
"productionPublicBaseURL": "http://productionPublicBaseURL",
562+
"stagingPublicBaseURL": "http://stagingPublicBaseURL",
563+
"productSystemName": "PrOdUcTsYsTeMnAmE",
564+
"privateBaseURL": "http://privateBaseURL",
565+
"prefixMatching": True,
566+
"privateAPIHostHeader": "privateAPIHostHeader",
567+
"privateAPISecretToken": "privateAPISecretToken",
568+
"body": active_docs_body,
569+
}
558570
return params
559571

560572

@@ -610,7 +622,7 @@ def policy_registry_params(policy_registry_schema):
610622
"""Params for policy registry."""
611623
suffix = get_suffix()
612624
name = f"test-{suffix}"
613-
return dict(name=name, version="0.1", schema=policy_registry_schema)
625+
return {"name": name, "version": "0.1", "schema": policy_registry_schema}
614626

615627

616628
@pytest.fixture(scope="module")
@@ -627,7 +639,7 @@ def policy_registry(api, policy_registry_params) -> PolicyRegistry:
627639
@pytest.fixture(scope="module")
628640
def limit_params(metric):
629641
"""Params for limit."""
630-
return dict(metric_id=metric["id"], period="minute", value=10)
642+
return {"metric_id": metric["id"], "period": "minute", "value": 10}
631643

632644

633645
@pytest.fixture(scope="module")
@@ -643,7 +655,7 @@ def limit(service, application, application_plan, metric, limit_params) -> Limit
643655
@pytest.fixture(scope="module")
644656
def backend_limit_params(backend_metric):
645657
"""Params for limit."""
646-
return dict(metric_id=backend_metric["id"], period="minute", value=10)
658+
return {"metric_id": backend_metric["id"], "period": "minute", "value": 10}
647659

648660

649661
@pytest.fixture(scope="module")
@@ -666,7 +678,7 @@ def backend_limit(
666678
@pytest.fixture(scope="module")
667679
def prule_params(metric):
668680
"""Params for prule."""
669-
return dict(metric_id=metric["id"], min=10, max=100, cost_per_unit="10")
681+
return {"metric_id": metric["id"], "min": 10, "max": 100, "cost_per_unit": "10"}
670682

671683

672684
@pytest.fixture(scope="module")
@@ -682,7 +694,12 @@ def prule(service, application, application_plan, metric, prule_params) -> Prici
682694
@pytest.fixture(scope="module")
683695
def backend_prule_params(backend_metric):
684696
"""Params for prule."""
685-
return dict(metric_id=backend_metric["id"], min=10, max=100, cost_per_unit=10)
697+
return {
698+
"metric_id": backend_metric["id"],
699+
"min": 10,
700+
"max": 100,
701+
"cost_per_unit": 10,
702+
}
686703

687704

688705
@pytest.fixture(scope="module")
@@ -709,7 +726,7 @@ def promote_params(api, service):
709726
"""
710727
Promote params for service.
711728
"""
712-
return dict(productCRName=service.crd.as_dict()["metadata"]["name"])
729+
return {"productCRName": service.crd.as_dict()["metadata"]["name"]}
713730

714731

715732
@pytest.fixture(scope="module")

threescale_api_crd/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ class ThreeScaleClientCRD(threescale_api.client.ThreeScaleClient):
1313
Threescale client for CRD.
1414
"""
1515

16-
def __init__(self, url, token, ocp_provider_ref=None, ocp_namespace=None, *args, **kwargs):
16+
def __init__(
17+
self, url, token, ocp_provider_ref=None, ocp_namespace=None, *args, **kwargs
18+
):
1719
super().__init__(url, token, *args, **kwargs)
1820
self._ocp_provider_ref = ocp_provider_ref
1921
self._ocp_namespace = ThreeScaleClientCRD.get_namespace(ocp_namespace)

0 commit comments

Comments
 (0)