Skip to content

Commit

Permalink
small pylint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mkudlej committed Nov 29, 2024
1 parent f1786ce commit 889f84f
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 112 deletions.
165 changes: 91 additions & 74 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def apicast_http_client(application, proxy, ssl_verify):
@pytest.fixture(scope="module")
def service_params():
suffix = get_suffix()
return dict(name=f"test-{suffix}")
return {"name": f"test-{suffix}"}


@pytest.fixture(scope="module")
Expand All @@ -135,14 +135,14 @@ def service(service_params, api) -> Service:
def account_params():
suffix = get_suffix()
name = f"testacc{suffix}"
return dict(
name=name,
username=name,
org_name=name,
monthly_billing_enabled=False,
monthly_charging_enabled=False,
email=f"{name}@name.none",
)
return {
"name": name,
"username": name,
"org_name": name,
"monthly_billing_enabled": False,
"monthly_charging_enabled": False,
"email": f"{name}@name.none",
}


@pytest.fixture(scope="module")
Expand All @@ -161,12 +161,12 @@ def acc_user(account):
@pytest.fixture(scope="module")
def acc_user2_params(account, acc_user):
name = acc_user["username"] + "2"
return dict(
username=name,
email=f"{name}@name.none",
role="member",
account_name=account["name"],
)
return {
"username": name,
"email": f"{name}@name.none",
"role": "member",
"account_name": account["name"],
}


@pytest.fixture(scope="module")
Expand All @@ -177,12 +177,12 @@ def acc_user2(account, acc_user, acc_user2_params):
@pytest.fixture(scope="module")
def application_plan_params(service) -> dict:
suffix = get_suffix()
return dict(
name=f"test-{suffix}",
setup_fee="1.00",
state_event="publish",
cost_per_month="3.00",
)
return {
"name": f"test-{suffix}",
"setup_fee": "1.00",
"state_event": "publish",
"cost_per_month": "3.00",
}


@pytest.fixture(scope="module")
Expand All @@ -196,13 +196,13 @@ def application_plan(api, service, application_plan_params) -> ApplicationPlan:
def application_params(application_plan, service, account):
suffix = get_suffix()
name = f"test-{suffix}"
return dict(
name=name,
description=name,
plan_id=application_plan["id"],
service_id=service["id"],
account_id=account["id"],
)
return {
"name": name,
"description": name,
"plan_id": application_plan["id"],
"service_id": service["id"],
"account_id": account["id"],
}


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -270,15 +270,15 @@ def metric_params(service):
suffix = get_suffix()
friendly_name = f"test-metric-{suffix}"
name = f"{friendly_name}".replace("-", "_")
return dict(friendly_name=friendly_name, system_name=name, unit="count")
return {"friendly_name": friendly_name, "system_name": name, "unit": "count"}


@pytest.fixture(scope="module")
def backend_metric_params():
suffix = get_suffix()
friendly_name = f"test-metric-{suffix}"
name = f"{friendly_name}".replace("-", "")
return dict(friendly_name=friendly_name, system_name=name, unit="count")
return {"friendly_name": friendly_name, "system_name": name, "unit": "count"}


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -310,7 +310,7 @@ def method_params():
suffix = get_suffix()
friendly_name = f"test-method-{suffix}"
system_name = f"{friendly_name}".replace("-", "_")
return dict(friendly_name=friendly_name, system_name=system_name)
return {"friendly_name": friendly_name, "system_name": system_name}


# 'friendly_name' is id in CRD for methods
Expand Down Expand Up @@ -347,7 +347,12 @@ def mapping_rule_params(service):
Fixture for getting paramteres for mapping rule for product/service.
"""
hits_metric = service.metrics.read_by_name("hits")
return dict(http_method="GET", pattern="/get", metric_id=hits_metric["id"], delta=1)
return {
"http_method": "GET",
"pattern": "/get",
"metric_id": hits_metric["id"],
"delta": 1,
}


@pytest.fixture(scope="module")
Expand All @@ -356,7 +361,12 @@ def backend_mapping_rule_params(backend, backend_metric):
Fixture for getting paramteres for mapping rule for backend.
"""
back = backend_metric["id"]
return dict(http_method="GET", pattern="/anything/get/ida", metric_id=back, delta=1)
return {
"http_method": "GET",
"pattern": "/anything/get/ida",
"metric_id": back,
"delta": 1,
}


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -414,13 +424,13 @@ def create_mapping_rule(service):
rules = []

def _create(metric, http_method, path):
params = dict(
service_id=service["id"],
http_method=http_method,
pattern=f"/anything{path}",
delta=1,
metric_id=metric["id"],
)
params = {
"service_id": service["id"],
"http_method": http_method,
"pattern": f"/anything{path}",
"delta": 1,
"metric_id": metric["id"],
}
rule = service.mapping_rules.create(params=params)
rules.append(rule)
return rule
Expand All @@ -441,13 +451,13 @@ def create_backend_mapping_rule(backend):
rules = []

def _create(backend_metric, http_method, path):
params = dict(
backend_id=backend["id"],
http_method=http_method,
pattern=f"/anything{path}",
delta=1,
metric_id=backend_metric["id"],
)
params = {
"backend_id": backend["id"],
"http_method": http_method,
"pattern": f"/anything{path}",
"delta": 1,
"metric_id": backend_metric["id"],
}
rule = backend.mapping_rules.create(params=params)
rules.append(rule)
return rule
Expand All @@ -465,9 +475,11 @@ def backend_params(api_backend):
Fixture for getting backend parameters.
"""
suffix = get_suffix()
return dict(
name=f"test-backend-{suffix}", private_endpoint=api_backend, description="111"
)
return {
"name": f"test-backend-{suffix}",
"private_endpoint": api_backend,
"description": "111",
}


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -505,12 +517,12 @@ def tenant_params():
"""
Params for custom tenant
"""
return dict(
username=f"tenant{get_suffix()}",
admin_password="123456",
email=f"e{get_suffix()}@invalid.invalid",
org_name="org",
)
return {
"username": f"tenant{get_suffix()}",
"admin_password": "123456",
"email": f"e{get_suffix()}@invalid.invalid",
"org_name": "org",
}


@pytest.fixture(scope="module")
Expand All @@ -525,7 +537,7 @@ def active_docs_params(active_docs_body):
suffix = get_suffix()
name = f"test-{suffix}"
des = f"description-{suffix}"
return dict(name=name, body=active_docs_body, description=des)
return {"name": name, "body": active_docs_body, "description": des}


@pytest.fixture(scope="module")
Expand All @@ -544,17 +556,17 @@ def active_doc(api, service, active_docs_params) -> ActiveDoc:
def openapi_params(active_docs_body):
suffix = get_suffix()
name = f"test-{suffix}"
params = dict(
name=name,
productionPublicBaseURL="http://productionPublicBaseURL",
stagingPublicBaseURL="http://stagingPublicBaseURL",
productSystemName="PrOdUcTsYsTeMnAmE",
privateBaseURL="http://privateBaseURL",
prefixMatching=True,
privateAPIHostHeader="privateAPIHostHeader",
privateAPISecretToken="privateAPISecretToken",
body=active_docs_body,
)
params = {
"name": name,
"productionPublicBaseURL": "http://productionPublicBaseURL",
"stagingPublicBaseURL": "http://stagingPublicBaseURL",
"productSystemName": "PrOdUcTsYsTeMnAmE",
"privateBaseURL": "http://privateBaseURL",
"prefixMatching": True,
"privateAPIHostHeader": "privateAPIHostHeader",
"privateAPISecretToken": "privateAPISecretToken",
"body": active_docs_body,
}
return params


Expand Down Expand Up @@ -610,7 +622,7 @@ def policy_registry_params(policy_registry_schema):
"""Params for policy registry."""
suffix = get_suffix()
name = f"test-{suffix}"
return dict(name=name, version="0.1", schema=policy_registry_schema)
return {"name": name, "version": "0.1", "schema": policy_registry_schema}


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


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


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


@pytest.fixture(scope="module")
Expand All @@ -682,7 +694,12 @@ def prule(service, application, application_plan, metric, prule_params) -> Prici
@pytest.fixture(scope="module")
def backend_prule_params(backend_metric):
"""Params for prule."""
return dict(metric_id=backend_metric["id"], min=10, max=100, cost_per_unit=10)
return {
"metric_id": backend_metric["id"],
"min": 10,
"max": 100,
"cost_per_unit": 10,
}


@pytest.fixture(scope="module")
Expand All @@ -709,7 +726,7 @@ def promote_params(api, service):
"""
Promote params for service.
"""
return dict(productCRName=service.crd.as_dict()["metadata"]["name"])
return {"productCRName": service.crd.as_dict()["metadata"]["name"]}


@pytest.fixture(scope="module")
Expand Down
4 changes: 3 additions & 1 deletion threescale_api_crd/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ class ThreeScaleClientCRD(threescale_api.client.ThreeScaleClient):
Threescale client for CRD.
"""

def __init__(self, url, token, ocp_provider_ref=None, ocp_namespace=None, *args, **kwargs):
def __init__(
self, url, token, ocp_provider_ref=None, ocp_namespace=None, *args, **kwargs
):
super().__init__(url, token, *args, **kwargs)
self._ocp_provider_ref = ocp_provider_ref
self._ocp_namespace = ThreeScaleClientCRD.get_namespace(ocp_namespace)
Expand Down
Loading

0 comments on commit 889f84f

Please sign in to comment.