diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index fa9bc9917..fd2a559d4 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -9,4 +9,7 @@ b0bf287f7f07c727c498deaa199f2629a3aac5a9 # black 24.1.1 changes 9261b5ae4bf0d53058e6adf2e5d2544011360ba7 # Change regarding flake8 check for python 3.12 d499948418f6e1dc432dabf11f158e58d9a0b0d8 # black 25.1.0 changes -5083c776e66ae613558918342ecf9f0a368f6e99 # isort --profile black +7619a4c61d7914b16088f585e2bceacebf26ec88 # reduce new lines to one after import block +a5deb34f80c6644936cb192686ded29a292d1e8f # unpacking tuple does not need () on lhs +80bb9d6d9f11ac33d6c9287261d2ce44aadd3f87 # fix type ignore comment +1894935618597e2d219e17fa7b1fd0b0fa919515 # isort --profile black diff --git a/Makefile b/Makefile index e024b23b1..3f3f639c7 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ ifeq ($(filter-out --store --load,$(flags)),$(flags)) endif commit-acceptance: ## Run all linters, checks, formatters -commit-acceptance: pylint flake8 mypy all-is-package black-check +commit-acceptance: pylint flake8 mypy all-is-package black-check isort-check pylint flake8 mypy: pipenv-dev pipenv run $@ $(flags) testsuite @@ -57,6 +57,9 @@ pylint flake8 mypy: pipenv-dev black-check: pipenv-dev pipenv run black --check testsuite +isort-check: pipenv-dev + pipenv run isort -c --profile black testsuite + all-is-package: @echo @echo "Searching for dirs missing __init__.py" diff --git a/Pipfile b/Pipfile index f2ed6d254..4f771424c 100644 --- a/Pipfile +++ b/Pipfile @@ -9,6 +9,9 @@ types-braintree = "*" types-stripe = "*" types-Pillow = "*" black = "*" +isort = "*" +# this will use system ca-bundle +pip-system-certs = "*" # Have commented out python-language-server to make it available quickly # for the development #python-language-server = "*" @@ -30,7 +33,7 @@ pytest-asyncio = "==0.21.2" requests = "*" dynaconf = "*" python-keycloak = ">=4.7.3" # this fix needed: https://github.com/marcospereirampj/python-keycloak/pull/622/files -backoff = "*" +python-backoff = "*" websocket_client = "==1.5.1" httpx = {version = "*", extras = ["http2"]} selenium = ">=4.0.0" diff --git a/scripts/junit2reportportal b/scripts/junit2reportportal index 78782d58c..139575117 100755 --- a/scripts/junit2reportportal +++ b/scripts/junit2reportportal @@ -59,6 +59,8 @@ token = os.environ[args.token_variable] reportportal = args.reportportal.rstrip("/") auth = {"Authorization": f"Bearer {token}"} -launch_import = f"{reportportal}/api/v1/{args.project}/launch/import" +launch_import = f"{reportportal}/api/v1/plugin/{args.project}/junit/import" -print(requests.post(launch_import, files={"file": (f"{args.launch_name}.zip", stream.getbuffer(), "application/zip")}, headers=auth).text) +print(requests.post(launch_import, files={"file": (f"{args.launch_name}.zip", stream.getbuffer(), "application/zip"), + "launchImportRq": (None, f'{{"name": "{args.launch_name}"}}', "application/json")}, + headers=auth).text) diff --git a/setup.cfg b/setup.cfg index 5bc22a88e..f68521f3e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,5 +2,8 @@ max-line-length = 120 ignore = E203,W503 +[isort] +profile = "black" + [mypy] ignore_missing_imports = True diff --git a/testsuite/__init__.py b/testsuite/__init__.py index e925bf8e4..7ab8e0fac 100644 --- a/testsuite/__init__.py +++ b/testsuite/__init__.py @@ -20,10 +20,11 @@ handler.setFormatter(formatter) logger.addHandler(handler) -from pathlib import Path # noqa -from packaging.version import Version # noqa -from weakget import weakget +from pathlib import Path + import importlib_resources as resources +from packaging.version import Version +from weakget import weakget from testsuite.config import settings # noqa diff --git a/testsuite/billing.py b/testsuite/billing.py index f14f966c7..a3d811dd7 100644 --- a/testsuite/billing.py +++ b/testsuite/billing.py @@ -5,35 +5,34 @@ import stripe from braintree.exceptions.request_timeout_error import RequestTimeoutError from braintree.exceptions.service_unavailable_error import ServiceUnavailableError - from threescale_api.resources import InvoiceState class Stripe: """API for Stripe""" - def __init__(self, api_key): + def __init__(self, api_key, provider_account_id): # Due to fact that we can set up only one Stripe per 3scale and we use same api_key everytime this # is not disruptive even if it looks like it is. stripe.api_key = api_key + self.provider_account_id = provider_account_id @staticmethod @backoff.on_predicate(backoff.fibo, lambda x: x == [], max_tries=10, jitter=None) def read_charge(customer): """Retrieves the details of the charge""" - return stripe.Charge.search(query=f"customer:'{customer['id']}'").get("data") + return stripe.Charge.search(query=f"customer:'{customer['id']}'").data - @staticmethod @backoff.on_exception(backoff.expo, IndexError, max_tries=4, jitter=None) - def read_customer_by_account(account): + def read_customer_by_account(self, account): """ Read Stripe customer. Different 3scale deployments can have customers with the same id, which is reflected to the `3scale_account_reference` Stripe Customer variable. This method reads just the last one. """ return stripe.Customer.search( - query=f"metadata['3scale_account_reference']:'3scale-2-{str(account.entity_id)}'" - ).get("data")[0] + query=f"metadata['3scale_account_reference']:'3scale-{self.provider_account_id}-{str(account.entity_id)}'" + ).data[0] def assert_payment(self, invoice, account): """Compare 3scale and Stripe invoices""" @@ -51,7 +50,7 @@ def assert_payment(self, invoice, account): class Braintree: """API for braintree""" - def __init__(self, merchant_id, public_key, private_key): + def __init__(self, merchant_id, public_key, private_key, provider_account_id): self.gateway = braintree.BraintreeGateway( braintree.Configuration( environment=braintree.Environment.Sandbox, @@ -60,6 +59,7 @@ def __init__(self, merchant_id, public_key, private_key): private_key=private_key, ) ) + self.provider_account_id = provider_account_id @backoff.on_exception(backoff.fibo, (ServiceUnavailableError, RequestTimeoutError), max_tries=8, jitter=None) def get_customer_transactions(self, account): @@ -76,10 +76,9 @@ def merchant_currency(self): merchant_accounts = list(self.gateway.merchant_account.all().merchant_accounts.items) return [x for x in merchant_accounts if x.default is True][0].currency_iso_code - @staticmethod - def customer_id(account): - """Returns Braintree customer id. It is in a form `3scale-2-{account_id}-1`""" - return f"3scale-2-{account.entity_id}-1" + def customer_id(self, account): + """Returns Braintree customer id. It is in a form `3scale-{provider_id}-{account_id}-1`""" + return f"3scale-{self.provider_account_id}-{account.entity_id}-1" @staticmethod def _assert_transaction(invoice, transaction): diff --git a/testsuite/capabilities/__init__.py b/testsuite/capabilities/__init__.py index 6623a5468..7eef8e0c4 100644 --- a/testsuite/capabilities/__init__.py +++ b/testsuite/capabilities/__init__.py @@ -7,7 +7,7 @@ """ import enum -from typing import Set, Callable, Any, Tuple, List +from typing import Any, Callable, List, Set, Tuple # Users should have access only to these public methods/decorators __all__ = ["CapabilityRegistry", "Capability"] diff --git a/testsuite/capabilities/providers.py b/testsuite/capabilities/providers.py index 5b275c387..780752597 100644 --- a/testsuite/capabilities/providers.py +++ b/testsuite/capabilities/providers.py @@ -1,9 +1,9 @@ """This module is where most of the capability providers should be to not have them scattered around""" from testsuite import gateways -from testsuite.capabilities import CapabilityRegistry, Capability -from testsuite.configuration import openshift +from testsuite.capabilities import Capability, CapabilityRegistry from testsuite.config import settings +from testsuite.configuration import openshift def gateway_capabilities(): diff --git a/testsuite/certificates/__init__.py b/testsuite/certificates/__init__.py index 823dda09a..c1cbed1b4 100644 --- a/testsuite/certificates/__init__.py +++ b/testsuite/certificates/__init__.py @@ -1,7 +1,7 @@ """Collection of classes for working with different ssl certificate tools.""" from abc import ABC, abstractmethod -from typing import List, Optional, Tuple, Dict +from typing import Dict, List, Optional, Tuple from testsuite.certificates.persist import TmpFilePersist diff --git a/testsuite/certificates/cfssl/cli.py b/testsuite/certificates/cfssl/cli.py index 332847ce6..3b059bb53 100644 --- a/testsuite/certificates/cfssl/cli.py +++ b/testsuite/certificates/cfssl/cli.py @@ -3,11 +3,16 @@ import json import os import subprocess -from typing import Optional, List, Tuple, Dict, Any +from typing import Any, Dict, List, Optional, Tuple import importlib_resources as resources -from testsuite.certificates import KeyProvider, SigningProvider, Certificate, UnsignedKey +from testsuite.certificates import ( + Certificate, + KeyProvider, + SigningProvider, + UnsignedKey, +) from testsuite.certificates.cfssl import CFSSLException diff --git a/testsuite/certificates/stores.py b/testsuite/certificates/stores.py index 8b18b5217..aa821de01 100644 --- a/testsuite/certificates/stores.py +++ b/testsuite/certificates/stores.py @@ -5,7 +5,7 @@ from abc import ABC from typing import Dict -from testsuite.certificates import CertificateStore, Certificate +from testsuite.certificates import Certificate, CertificateStore def _persist(path, name: str, ext: str, content: str): diff --git a/testsuite/configuration.py b/testsuite/configuration.py index 79001e948..377b9002f 100644 --- a/testsuite/configuration.py +++ b/testsuite/configuration.py @@ -1,12 +1,12 @@ """Module responsible for processing configuration""" import inspect -from typing import Dict, Any, Mapping +from typing import Any, Dict, Mapping from weakget import weakget -from testsuite.config import settings from testsuite.capabilities import Singleton +from testsuite.config import settings from testsuite.openshift.client import OpenShiftClient diff --git a/testsuite/dynaconf_loader.py b/testsuite/dynaconf_loader.py index ef4b6d719..173bf9de9 100644 --- a/testsuite/dynaconf_loader.py +++ b/testsuite/dynaconf_loader.py @@ -18,16 +18,16 @@ load() is doubled. """ -from pathlib import Path import logging import os import os.path import re +from pathlib import Path -from packaging.version import Version, InvalidVersion +from openshift_client import OpenShiftPythonException +from packaging.version import InvalidVersion, Version from weakget import weakget -from openshift_client import OpenShiftPythonException from testsuite.openshift.client import OpenShiftClient log = logging.getLogger(__name__) # pylint: disable=invalid-name diff --git a/testsuite/gateway_logs.py b/testsuite/gateway_logs.py index bf9cc7bcb..5e7c28955 100644 --- a/testsuite/gateway_logs.py +++ b/testsuite/gateway_logs.py @@ -1,7 +1,7 @@ """Pytest plugin for collecting gateway logs""" -from datetime import datetime, timezone import logging +from datetime import datetime, timezone import pytest from _pytest.outcomes import Skipped diff --git a/testsuite/gateways/apicast/__init__.py b/testsuite/gateways/apicast/__init__.py index ac7d4e5da..a84497ddd 100644 --- a/testsuite/gateways/apicast/__init__.py +++ b/testsuite/gateways/apicast/__init__.py @@ -1,17 +1,16 @@ """Module containing all APIcast gateways""" +import logging from abc import ABC, abstractmethod from datetime import datetime -from typing import Optional, List, Dict, Tuple -import logging +from typing import Dict, List, Optional, Tuple from openshift_client import OpenShiftPythonException - from threescale_api.resources import Service +from testsuite import utils from testsuite.capabilities import Capability from testsuite.gateways import AbstractGateway -from testsuite import utils from testsuite.openshift.client import OpenShiftClient from testsuite.openshift.deployments import Deployment from testsuite.openshift.env import Properties diff --git a/testsuite/gateways/apicast/operator.py b/testsuite/gateways/apicast/operator.py index 12cac84f0..ac2486b93 100644 --- a/testsuite/gateways/apicast/operator.py +++ b/testsuite/gateways/apicast/operator.py @@ -2,10 +2,9 @@ import re import time -from typing import Dict, Callable, Pattern, Any, Match, Union +from typing import Any, Callable, Dict, Match, Pattern, Union from openshift_client import OpenShiftPythonException - from weakget import weakget from testsuite import settings diff --git a/testsuite/gateways/apicast/selfmanaged.py b/testsuite/gateways/apicast/selfmanaged.py index e9fecf7ea..6a3482373 100644 --- a/testsuite/gateways/apicast/selfmanaged.py +++ b/testsuite/gateways/apicast/selfmanaged.py @@ -2,13 +2,13 @@ import inspect import logging -from typing import Union, Type +from typing import Type, Union from weakget import weakget from testsuite.capabilities import Capability -from testsuite.gateways.gateways import Gateway, new_gateway from testsuite.gateways.apicast import AbstractApicast, OpenshiftApicast +from testsuite.gateways.gateways import Gateway, new_gateway from testsuite.openshift.client import OpenShiftClient LOGGER = logging.getLogger(__name__) diff --git a/testsuite/gateways/apicast/system.py b/testsuite/gateways/apicast/system.py index 09479eef4..78aec7ec7 100644 --- a/testsuite/gateways/apicast/system.py +++ b/testsuite/gateways/apicast/system.py @@ -3,7 +3,6 @@ from typing import TYPE_CHECKING import backoff - from openshift_client import OpenShiftPythonException from testsuite.capabilities import Capability diff --git a/testsuite/gateways/apicast/template.py b/testsuite/gateways/apicast/template.py index f0dfa7bff..dc1d81f35 100644 --- a/testsuite/gateways/apicast/template.py +++ b/testsuite/gateways/apicast/template.py @@ -5,8 +5,9 @@ import importlib_resources as resources -from testsuite.openshift.objects import SecretTypes from testsuite.openshift.client import OpenShiftClient +from testsuite.openshift.objects import SecretTypes + from . import OpenshiftApicast LOGGER = logging.getLogger(__name__) diff --git a/testsuite/gateways/apicast/tls.py b/testsuite/gateways/apicast/tls.py index 95bfcd7f6..0fe5faa24 100644 --- a/testsuite/gateways/apicast/tls.py +++ b/testsuite/gateways/apicast/tls.py @@ -7,13 +7,14 @@ from threescale_api.resources import Application, Service from testsuite.openshift.objects import Routes, SecretKinds -from . import AbstractApicast, OpenshiftApicast -from .selfmanaged import SelfManagedApicast -from .. import new_gateway + from ... import settings from ...capabilities import Capability from ...certificates import Certificate from ...openshift.env import Properties +from .. import new_gateway +from . import AbstractApicast, OpenshiftApicast +from .selfmanaged import SelfManagedApicast LOGGER = logging.getLogger(__name__) diff --git a/testsuite/gateways/service_mesh/__init__.py b/testsuite/gateways/service_mesh/__init__.py index 6fb76e841..70068e48c 100644 --- a/testsuite/gateways/service_mesh/__init__.py +++ b/testsuite/gateways/service_mesh/__init__.py @@ -2,7 +2,7 @@ from typing import Dict -from threescale_api.resources import Service, Application +from threescale_api.resources import Application, Service from testsuite.capabilities import Capability from testsuite.gateways.gateways import AbstractGateway diff --git a/testsuite/gateways/wasm/__init__.py b/testsuite/gateways/wasm/__init__.py index b408da534..2b6af7f28 100644 --- a/testsuite/gateways/wasm/__init__.py +++ b/testsuite/gateways/wasm/__init__.py @@ -4,7 +4,7 @@ from urllib.parse import urlparse import importlib_resources as resources -from threescale_api.resources import Service, Application +from threescale_api.resources import Application, Service from testsuite.capabilities import Capability from testsuite.gateways import AbstractGateway diff --git a/testsuite/httpx.py b/testsuite/httpx.py index 2a1582bfd..ac8652ab1 100644 --- a/testsuite/httpx.py +++ b/testsuite/httpx.py @@ -2,13 +2,21 @@ import functools import logging -from typing import Iterable, Generator +from typing import Generator, Iterable -from httpx import Client, Request, Response, URL, Auth, create_ssl_context, USE_CLIENT_DEFAULT -from threescale_api.resources import Application, Service -from threescale_api.utils import response2str, request2curl import backoff import httpx +from httpx import ( + URL, + USE_CLIENT_DEFAULT, + Auth, + Client, + Request, + Response, + create_ssl_context, +) +from threescale_api.resources import Application, Service +from threescale_api.utils import request2curl, response2str from testsuite.lifecycle_hook import LifecycleHook diff --git a/testsuite/jaeger.py b/testsuite/jaeger.py index 541462f24..3567d4a7b 100644 --- a/testsuite/jaeger.py +++ b/testsuite/jaeger.py @@ -5,9 +5,10 @@ from string import Template from urllib.parse import urlparse + import backoff -import requests import importlib_resources as resources +import requests class Jaeger: diff --git a/testsuite/lifecycle_hook.py b/testsuite/lifecycle_hook.py index 389dfaa5e..f5e5460ed 100644 --- a/testsuite/lifecycle_hook.py +++ b/testsuite/lifecycle_hook.py @@ -4,7 +4,7 @@ import abc -from threescale_api.resources import Application, Service, Backend +from threescale_api.resources import Application, Backend, Service class LifecycleHook(abc.ABC): diff --git a/testsuite/mailhog.py b/testsuite/mailhog.py index 8416981e8..e4198cad5 100644 --- a/testsuite/mailhog.py +++ b/testsuite/mailhog.py @@ -2,15 +2,15 @@ This module contains wrapper for the Mailhog API """ -from typing import Set, Optional +from typing import Optional, Set + import backoff import pytest import requests - from openshift_client import OpenShiftPythonException -from testsuite.utils import warn_and_skip from testsuite.openshift.client import OpenShiftClient +from testsuite.utils import warn_and_skip class MailhogClient: @@ -86,7 +86,7 @@ def get_messages_by_chunk(self, chunk_size: int = 250, limit: Optional[int] = No yield messages # pylint: disable=too-many-arguments, too-many-boolean-expressions - def find_message(self, subject=None, content=None, sender=None, receiver=None): + def find_messages(self, subject=None, content=None, sender=None, receiver=None): """Searches for messages by content, subject, sender, receiver CHeck presence of all provided values""" matching_messages = [] @@ -130,6 +130,6 @@ def assert_message_received(self, expected_count=1, subject=None, content=None, @param content: content of message to search for @param expected_count: number of expected messages """ - messages = self.find_message(subject, content, sender, receiver) + messages = self.find_messages(subject, content, sender, receiver) assert messages["count"] == expected_count, f"Expected {expected_count} mail, found {messages['count']}" return messages diff --git a/testsuite/mockserver.py b/testsuite/mockserver.py index 17ec552d5..2968693e3 100644 --- a/testsuite/mockserver.py +++ b/testsuite/mockserver.py @@ -1,12 +1,12 @@ """Represents mockserver calls used in tests""" -from urllib.parse import urljoin import json +from urllib.parse import urljoin -from requests import HTTPError -from weakget import weakget import backoff import requests +from requests import HTTPError +from weakget import weakget from testsuite.utils import generate_tail diff --git a/testsuite/openshift/client.py b/testsuite/openshift/client.py index 19fc141c4..163984877 100644 --- a/testsuite/openshift/client.py +++ b/testsuite/openshift/client.py @@ -1,19 +1,23 @@ """This module implements an openshift interface with openshift oc client wrapper.""" import enum -from functools import cached_property import json import os from contextlib import ExitStack -from typing import List, Dict, Union, Any, Optional, Callable, Sequence +from functools import cached_property +from typing import Any, Callable, Dict, List, Optional, Sequence, Union import openshift_client as oc import yaml from testsuite.openshift.crd.apimanager import APIManager from testsuite.openshift.crd.operator import Operator -from testsuite.openshift.deployments import KubernetesDeployment, DeploymentConfig, Deployment -from testsuite.openshift.objects import Secrets, ConfigMaps, Routes +from testsuite.openshift.deployments import ( + Deployment, + DeploymentConfig, + KubernetesDeployment, +) +from testsuite.openshift.objects import ConfigMaps, Routes, Secrets from testsuite.openshift.scaler import Scaler diff --git a/testsuite/openshift/deployments.py b/testsuite/openshift/deployments.py index 7f9fc6bd4..393eb4b94 100644 --- a/testsuite/openshift/deployments.py +++ b/testsuite/openshift/deployments.py @@ -7,6 +7,7 @@ from datetime import timezone import openshift_client as oc + from testsuite.openshift.env import Environ if typing.TYPE_CHECKING: diff --git a/testsuite/openshift/env.py b/testsuite/openshift/env.py index aab9ddcb4..f3d2182e5 100644 --- a/testsuite/openshift/env.py +++ b/testsuite/openshift/env.py @@ -1,9 +1,9 @@ """Module containing classes that manipulate deployment configs environment""" import abc -import re import logging -from typing import TYPE_CHECKING, Match, Dict +import re +from typing import TYPE_CHECKING, Dict, Match if TYPE_CHECKING: # pylint: disable=cyclic-import diff --git a/testsuite/openshift/objects.py b/testsuite/openshift/objects.py index b4b3f4927..b912bd3e2 100644 --- a/testsuite/openshift/objects.py +++ b/testsuite/openshift/objects.py @@ -6,6 +6,7 @@ import typing from io import StringIO from typing import List, Union + import yaml from testsuite.certificates import Certificate diff --git a/testsuite/perf_utils.py b/testsuite/perf_utils.py index a2bcfb4c2..ede61e913 100644 --- a/testsuite/perf_utils.py +++ b/testsuite/perf_utils.py @@ -4,10 +4,10 @@ import os from urllib.parse import urlparse -import importlib_resources as resources +import importlib_resources as resources import yaml -from hyperfoil.factories import HyperfoilFactory, Benchmark +from hyperfoil.factories import Benchmark, HyperfoilFactory def _load_benchmark(filename): diff --git a/testsuite/prometheus.py b/testsuite/prometheus.py index d06e3cb98..e85ca9d64 100644 --- a/testsuite/prometheus.py +++ b/testsuite/prometheus.py @@ -4,7 +4,7 @@ import time from datetime import datetime, timedelta, timezone from math import ceil -from typing import Optional, Callable, Dict +from typing import Callable, Dict, Optional from urllib.parse import urljoin import backoff diff --git a/testsuite/rawobj.py b/testsuite/rawobj.py index f3734087f..042530202 100644 --- a/testsuite/rawobj.py +++ b/testsuite/rawobj.py @@ -1,7 +1,7 @@ # pylint: disable=invalid-name "These are constructors to create native 3scale API objects" -from typing import TYPE_CHECKING, Optional, List +from typing import TYPE_CHECKING, List, Optional if TYPE_CHECKING: from threescale_api import resources diff --git a/testsuite/requestbin.py b/testsuite/requestbin.py index 882c8096d..2f925f9d5 100644 --- a/testsuite/requestbin.py +++ b/testsuite/requestbin.py @@ -3,9 +3,9 @@ """ import xml.etree.ElementTree as Et -import requests import backoff +import requests # pylint: disable=too-few-public-methods diff --git a/testsuite/resilient.py b/testsuite/resilient.py index 6729cabcd..7a2ec666c 100644 --- a/testsuite/resilient.py +++ b/testsuite/resilient.py @@ -4,7 +4,6 @@ import time import backoff - from threescale_api.errors import ApiClientError log = logging.getLogger(__name__) diff --git a/testsuite/rhsso/__init__.py b/testsuite/rhsso/__init__.py index 8c01ddf45..47edabc98 100644 --- a/testsuite/rhsso/__init__.py +++ b/testsuite/rhsso/__init__.py @@ -10,7 +10,7 @@ from threescale_api.utils import HttpClient from testsuite.httpx import HttpxOidcClientAuth -from testsuite.rhsso.objects import Realm, Client, RHSSO, Token +from testsuite.rhsso.objects import RHSSO, Client, Realm, Token class RHSSOServiceConfiguration: diff --git a/testsuite/rhsso/rhsso.py b/testsuite/rhsso/rhsso.py index 674019586..fb7bdd4eb 100644 --- a/testsuite/rhsso/rhsso.py +++ b/testsuite/rhsso/rhsso.py @@ -1,4 +1,8 @@ """Module for backward compatibility of RHSSO imports, safe to delete if all references are changed""" # pylint: disable=unused-import -from . import RHSSOServiceConfiguration, OIDCClientAuth, OIDCClientAuthHook # noqa: F401 +from . import ( # noqa: F401 + OIDCClientAuth, + OIDCClientAuthHook, + RHSSOServiceConfiguration, +) diff --git a/testsuite/tests/apicast/apiap/routing/test_routing.py b/testsuite/tests/apicast/apiap/routing/test_routing.py index 879bf8580..d762e9047 100644 --- a/testsuite/tests/apicast/apiap/routing/test_routing.py +++ b/testsuite/tests/apicast/apiap/routing/test_routing.py @@ -4,17 +4,16 @@ import pytest import pytest_cases +from packaging.version import Version from pytest_cases import parametrize_with_cases -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import rawobj +from testsuite import TESTED_VERSION, rawobj from testsuite.echoed_request import EchoedRequest from testsuite.tests.apicast.apiap.routing import routing_cases from testsuite.utils import blame -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.8.2')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.8.2"), reason="TESTED_VERSION < Version('2.8.2')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-4937"), ] @@ -68,13 +67,17 @@ def client(staging_gateway, application): @pytest_cases.parametrize( "append_slash", [ - pytest.param(True, id="2.10_legacy", marks=[pytest.mark.skipif("TESTED_VERSION >= Version('2.11')")]), + pytest.param( + True, + id="2.10_legacy", + marks=[pytest.mark.skipif(TESTED_VERSION >= Version("2.11"), reason="TESTED_VERSION >= Version('2.11')")], + ), pytest.param( False, id="", marks=[ pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-7146"), - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), ], ), ], diff --git a/testsuite/tests/apicast/apiap/special_chars/test_utf_8.py b/testsuite/tests/apicast/apiap/special_chars/test_utf_8.py index 0d44a1d1c..d83c294b3 100644 --- a/testsuite/tests/apicast/apiap/special_chars/test_utf_8.py +++ b/testsuite/tests/apicast/apiap/special_chars/test_utf_8.py @@ -5,7 +5,7 @@ https://www.w3schools.com/tags/ref_urlencode.ASP """ -from urllib.parse import urlparse, quote +from urllib.parse import quote, urlparse import pytest diff --git a/testsuite/tests/apicast/apiap/special_chars/test_windows_1252.py b/testsuite/tests/apicast/apiap/special_chars/test_windows_1252.py index f56c7e4a3..d86d026a4 100644 --- a/testsuite/tests/apicast/apiap/special_chars/test_windows_1252.py +++ b/testsuite/tests/apicast/apiap/special_chars/test_windows_1252.py @@ -5,14 +5,14 @@ from urllib.parse import urlparse import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.echoed_request import EchoedRequest -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import pytestmark = [ pytest.mark.xfail, - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6834"), ] diff --git a/testsuite/tests/apicast/apiap/test_apiap_routing_to_backend.py b/testsuite/tests/apicast/apiap/test_apiap_routing_to_backend.py index 674c89f0b..85f35f444 100644 --- a/testsuite/tests/apicast/apiap/test_apiap_routing_to_backend.py +++ b/testsuite/tests/apicast/apiap/test_apiap_routing_to_backend.py @@ -5,12 +5,13 @@ from urllib.parse import urlparse import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from packaging.version import Version + +from testsuite import TESTED_VERSION, rawobj from testsuite.echoed_request import EchoedRequest pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.8.1')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.8.1"), reason="TESTED_VERSION < Version('2.8.1')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-4904"), ] diff --git a/testsuite/tests/apicast/apiap/test_apiap_routing_with_backend_metrics.py b/testsuite/tests/apicast/apiap/test_apiap_routing_with_backend_metrics.py index 6ba92d033..97da1bd19 100644 --- a/testsuite/tests/apicast/apiap/test_apiap_routing_with_backend_metrics.py +++ b/testsuite/tests/apicast/apiap/test_apiap_routing_with_backend_metrics.py @@ -3,12 +3,13 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from packaging.version import Version + +from testsuite import TESTED_VERSION, rawobj # case[N] fixtures create tests that have to be executed in specific order, satisfied by loadfile pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.9')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-3623"), ] diff --git a/testsuite/tests/apicast/apiap/test_apiap_routing_with_product_mapping.py b/testsuite/tests/apicast/apiap/test_apiap_routing_with_product_mapping.py index 41edaadea..988e68042 100644 --- a/testsuite/tests/apicast/apiap/test_apiap_routing_with_product_mapping.py +++ b/testsuite/tests/apicast/apiap/test_apiap_routing_with_product_mapping.py @@ -3,11 +3,12 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from packaging.version import Version + +from testsuite import TESTED_VERSION, rawobj pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.8.1')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.8.1"), reason="TESTED_VERSION < Version('2.8.1')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-4736"), ] diff --git a/testsuite/tests/apicast/apiap/test_proxy_config.py b/testsuite/tests/apicast/apiap/test_proxy_config.py index 5244cf610..ef9245e23 100644 --- a/testsuite/tests/apicast/apiap/test_proxy_config.py +++ b/testsuite/tests/apicast/apiap/test_proxy_config.py @@ -2,14 +2,13 @@ Update api_backend on service without backend configured """ -from packaging.version import Version # noqa # pylint: disable=unused-import - import pytest +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.9')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-3626"), ] diff --git a/testsuite/tests/apicast/apiap/test_public_base_url.py b/testsuite/tests/apicast/apiap/test_public_base_url.py index 516496499..04d6b1f27 100644 --- a/testsuite/tests/apicast/apiap/test_public_base_url.py +++ b/testsuite/tests/apicast/apiap/test_public_base_url.py @@ -1,14 +1,14 @@ """Test for Public Base URLs as localhost""" import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version from threescale_api.errors import ApiClientError -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION pytestmark = [ pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-7149"), - pytest.mark.skipif("TESTED_VERSION < Version('2.12')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.12"), reason="TESTED_VERSION < Version('2.12')"), ] diff --git a/testsuite/tests/apicast/auth/rhsso/test_oidc_rhsso_jwt_client_id.py b/testsuite/tests/apicast/auth/rhsso/test_oidc_rhsso_jwt_client_id.py index 44fada49f..673b44e18 100644 --- a/testsuite/tests/apicast/auth/rhsso/test_oidc_rhsso_jwt_client_id.py +++ b/testsuite/tests/apicast/auth/rhsso/test_oidc_rhsso_jwt_client_id.py @@ -5,7 +5,6 @@ """ import pytest - from threescale_api.resources import Service diff --git a/testsuite/tests/apicast/auth/test_app_id.py b/testsuite/tests/apicast/auth/test_app_id.py index 5d43bbf3c..8b5dc4ead 100644 --- a/testsuite/tests/apicast/auth/test_app_id.py +++ b/testsuite/tests/apicast/auth/test_app_id.py @@ -8,8 +8,8 @@ from threescale_api.resources import Service from testsuite import rawobj -from testsuite.echoed_request import EchoedRequest from testsuite.capabilities import Capability +from testsuite.echoed_request import EchoedRequest from testsuite.utils import blame pytestmark = [pytest.mark.required_capabilities(Capability.PRODUCTION_GATEWAY), pytest.mark.disruptive] diff --git a/testsuite/tests/apicast/auth/test_basic_auth_app_id.py b/testsuite/tests/apicast/auth/test_basic_auth_app_id.py index ee58c65af..5648b0b29 100644 --- a/testsuite/tests/apicast/auth/test_basic_auth_app_id.py +++ b/testsuite/tests/apicast/auth/test_basic_auth_app_id.py @@ -4,10 +4,10 @@ """ import pytest +from packaging.version import Version from threescale_api.resources import Service -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.capabilities import Capability from testsuite.gateways.apicast.selfmanaged import SelfManagedApicast from testsuite.gateways.apicast.system import SystemApicast @@ -92,7 +92,7 @@ def test_basic_auth_failure(api_client, application, auth_method, expected_statu assert response.status_code == expected_status -@pytest.mark.skipif("TESTED_VERSION < Version('2.14')") +@pytest.mark.skipif(TESTED_VERSION < Version("2.14"), reason="TESTED_VERSION < Version('2.14')") @pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-11435") # pylint: disable=unused-argument def test_basic_auth_malformed_secret(http_client, valid_auth_headers, malformed_request, gateway_kind): diff --git a/testsuite/tests/apicast/auth/test_basic_auth_user_key.py b/testsuite/tests/apicast/auth/test_basic_auth_user_key.py index 53fdf4dbc..3714cb030 100644 --- a/testsuite/tests/apicast/auth/test_basic_auth_user_key.py +++ b/testsuite/tests/apicast/auth/test_basic_auth_user_key.py @@ -5,7 +5,6 @@ """ import pytest - from threescale_api.resources import Service from testsuite.utils import basic_auth_string diff --git a/testsuite/tests/apicast/auth/test_headers_app_id.py b/testsuite/tests/apicast/auth/test_headers_app_id.py index 481c0ee6f..33abdda27 100644 --- a/testsuite/tests/apicast/auth/test_headers_app_id.py +++ b/testsuite/tests/apicast/auth/test_headers_app_id.py @@ -5,7 +5,6 @@ """ import pytest - from threescale_api.resources import Service diff --git a/testsuite/tests/apicast/auth/test_headers_user_key.py b/testsuite/tests/apicast/auth/test_headers_user_key.py index 0f94529c9..a019ad8e7 100644 --- a/testsuite/tests/apicast/auth/test_headers_user_key.py +++ b/testsuite/tests/apicast/auth/test_headers_user_key.py @@ -5,7 +5,6 @@ """ import pytest - from threescale_api.resources import Service diff --git a/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_path_routing.py b/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_path_routing.py index 33f28c399..2cb9e5521 100644 --- a/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_path_routing.py +++ b/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_path_routing.py @@ -10,8 +10,8 @@ import pytest -from testsuite.echoed_request import EchoedRequest from testsuite.capabilities import Capability +from testsuite.echoed_request import EchoedRequest pytestmark = pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT) diff --git a/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_path_routing_disabled.py b/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_path_routing_disabled.py index 8f335683c..9ff70f811 100644 --- a/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_path_routing_disabled.py +++ b/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_path_routing_disabled.py @@ -7,8 +7,8 @@ import pytest -from testsuite.echoed_request import EchoedRequest from testsuite.capabilities import Capability +from testsuite.echoed_request import EchoedRequest pytestmark = pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT) diff --git a/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_path_routing_only.py b/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_path_routing_only.py index a04196cc1..d8befd264 100644 --- a/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_path_routing_only.py +++ b/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_path_routing_only.py @@ -10,8 +10,8 @@ import pytest -from testsuite.echoed_request import EchoedRequest from testsuite.capabilities import Capability +from testsuite.echoed_request import EchoedRequest from testsuite.gateways.apicast.template import TemplateApicast pytestmark = pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT) diff --git a/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_path_routing_query.py b/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_path_routing_query.py index e6786f819..23b51159d 100644 --- a/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_path_routing_query.py +++ b/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_path_routing_query.py @@ -3,16 +3,16 @@ """ import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import -from testsuite.echoed_request import EchoedRequest +from testsuite import TESTED_VERSION, rawobj from testsuite.capabilities import Capability +from testsuite.echoed_request import EchoedRequest pytestmark = [ pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-5149"), - pytest.mark.skipif("TESTED_VERSION < Version('2.9')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')"), ] diff --git a/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_service_oidc.py b/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_service_oidc.py index 2cb7a9ce0..0bfc11fc3 100644 --- a/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_service_oidc.py +++ b/testsuite/tests/apicast/parameters/apicast_path_routing/test_apicast_service_oidc.py @@ -4,8 +4,8 @@ import pytest -from testsuite.gateways import gateway from testsuite.capabilities import Capability +from testsuite.gateways import gateway from testsuite.gateways.apicast.template import TemplateApicast from testsuite.rhsso.rhsso import OIDCClientAuthHook from testsuite.utils import blame diff --git a/testsuite/tests/apicast/parameters/apicast_path_routing/test_mapping_rule_wrongly_matched.py b/testsuite/tests/apicast/parameters/apicast_path_routing/test_mapping_rule_wrongly_matched.py index 7dff1772c..670ca0bcd 100644 --- a/testsuite/tests/apicast/parameters/apicast_path_routing/test_mapping_rule_wrongly_matched.py +++ b/testsuite/tests/apicast/parameters/apicast_path_routing/test_mapping_rule_wrongly_matched.py @@ -4,13 +4,13 @@ """ import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.capabilities import Capability -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.9')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-4152"), pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT), ] diff --git a/testsuite/tests/apicast/parameters/auth/test_rhsso_wrong_realm.py b/testsuite/tests/apicast/parameters/auth/test_rhsso_wrong_realm.py index 31b290b67..5cc129e49 100644 --- a/testsuite/tests/apicast/parameters/auth/test_rhsso_wrong_realm.py +++ b/testsuite/tests/apicast/parameters/auth/test_rhsso_wrong_realm.py @@ -5,7 +5,7 @@ from testsuite.capabilities import Capability from testsuite.gateways.apicast.selfmanaged import SelfManagedApicast from testsuite.gateways.apicast.system import SystemApicast -from testsuite.rhsso import Token, OIDCClientAuthHook +from testsuite.rhsso import OIDCClientAuthHook, Token from testsuite.utils import blame diff --git a/testsuite/tests/apicast/parameters/conftest.py b/testsuite/tests/apicast/parameters/conftest.py index 00bd91160..f204a24b0 100644 --- a/testsuite/tests/apicast/parameters/conftest.py +++ b/testsuite/tests/apicast/parameters/conftest.py @@ -1,7 +1,7 @@ """Provide custom gateway for tests changing apicast parameters.""" -from weakget import weakget import pytest +from weakget import weakget from testsuite.gateways import gateway from testsuite.gateways.apicast.selfmanaged import SelfManagedApicast diff --git a/testsuite/tests/apicast/parameters/filter_by_url/test_oidc_timeout_err_filter_by_url.py b/testsuite/tests/apicast/parameters/filter_by_url/test_oidc_timeout_err_filter_by_url.py index 28e24b292..c0c6c8be5 100644 --- a/testsuite/tests/apicast/parameters/filter_by_url/test_oidc_timeout_err_filter_by_url.py +++ b/testsuite/tests/apicast/parameters/filter_by_url/test_oidc_timeout_err_filter_by_url.py @@ -12,19 +12,19 @@ from time import time -from packaging.version import Version # noqa # pylint: disable=unused-import import pytest +from packaging.version import Version from threescale_api.resources import Service +from testsuite import TESTED_VERSION from testsuite.capabilities import Capability from testsuite.gateways import gateway from testsuite.gateways.apicast.template import TemplateApicast from testsuite.utils import blame -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import pytestmark = [ pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT), - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6139"), pytest.mark.nopersistence, ] diff --git a/testsuite/tests/apicast/parameters/http_proxy/large_data/test_http_proxy_large_data.py b/testsuite/tests/apicast/parameters/http_proxy/large_data/test_http_proxy_large_data.py index 036b5e49a..49bd79c73 100644 --- a/testsuite/tests/apicast/parameters/http_proxy/large_data/test_http_proxy_large_data.py +++ b/testsuite/tests/apicast/parameters/http_proxy/large_data/test_http_proxy_large_data.py @@ -4,16 +4,16 @@ from urllib.parse import urlparse -from packaging.version import Version # noqa # pylint: disable=unused-import import pytest +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import -from testsuite.echoed_request import EchoedRequest +from testsuite import TESTED_VERSION from testsuite.capabilities import Capability +from testsuite.echoed_request import EchoedRequest from testsuite.utils import random_string pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.9')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-3863"), pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT), ] diff --git a/testsuite/tests/apicast/parameters/http_proxy/large_data/test_http_proxy_large_data_apiap.py b/testsuite/tests/apicast/parameters/http_proxy/large_data/test_http_proxy_large_data_apiap.py index 49b5b0afd..2ed2f35f2 100644 --- a/testsuite/tests/apicast/parameters/http_proxy/large_data/test_http_proxy_large_data_apiap.py +++ b/testsuite/tests/apicast/parameters/http_proxy/large_data/test_http_proxy_large_data_apiap.py @@ -5,16 +5,16 @@ from urllib.parse import urlparse -from packaging.version import Version # noqa # pylint: disable=unused-import import pytest +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import -from testsuite.echoed_request import EchoedRequest +from testsuite import TESTED_VERSION from testsuite.capabilities import Capability +from testsuite.echoed_request import EchoedRequest from testsuite.tests.toolbox.test_backend import random_string pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.9')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-3863"), pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT), ] diff --git a/testsuite/tests/apicast/parameters/http_proxy/test_http_proxy.py b/testsuite/tests/apicast/parameters/http_proxy/test_http_proxy.py index 339f893a5..0d286a585 100644 --- a/testsuite/tests/apicast/parameters/http_proxy/test_http_proxy.py +++ b/testsuite/tests/apicast/parameters/http_proxy/test_http_proxy.py @@ -5,8 +5,8 @@ import pytest -from testsuite.echoed_request import EchoedRequest from testsuite.capabilities import Capability +from testsuite.echoed_request import EchoedRequest pytestmark = [pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT)] diff --git a/testsuite/tests/apicast/parameters/http_proxy/test_https_proxy_extra_path.py b/testsuite/tests/apicast/parameters/http_proxy/test_https_proxy_extra_path.py index 36d5b9e24..6ed2504dd 100644 --- a/testsuite/tests/apicast/parameters/http_proxy/test_https_proxy_extra_path.py +++ b/testsuite/tests/apicast/parameters/http_proxy/test_https_proxy_extra_path.py @@ -2,12 +2,12 @@ from urllib.parse import urlparse -from packaging.version import Version # noqa # pylint: disable=unused-import import pytest +from packaging.version import Version +from testsuite import TESTED_VERSION from testsuite.capabilities import Capability from testsuite.echoed_request import EchoedRequest -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import pytestmark = [pytest.mark.required_capabilities(Capability.CUSTOM_ENVIRONMENT)] @@ -50,7 +50,7 @@ def gateway_environment(gateway_environment, testconfig, tools, rhsso_kind): @pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-8426") -@pytest.mark.skipif("TESTED_VERSION <= Version('2.12')") +@pytest.mark.skipif(TESTED_VERSION <= Version("2.12"), reason="TESTED_VERSION <= Version('2.12')") def test_https_proxy_extra_path(api_client, extra_path): """ Given private base url including extra path fragment /anything/else diff --git a/testsuite/tests/apicast/parameters/jaeger/conftest.py b/testsuite/tests/apicast/parameters/jaeger/conftest.py index 190eb0507..7cf56d207 100644 --- a/testsuite/tests/apicast/parameters/jaeger/conftest.py +++ b/testsuite/tests/apicast/parameters/jaeger/conftest.py @@ -2,8 +2,8 @@ Conftest for the jaeger tests """ -from weakget import weakget import pytest +from weakget import weakget from testsuite.jaeger import Jaeger diff --git a/testsuite/tests/apicast/parameters/jaeger/test_open_telemetry_apicast_integration.py b/testsuite/tests/apicast/parameters/jaeger/test_open_telemetry_apicast_integration.py index 5efbe7503..c64524d0d 100644 --- a/testsuite/tests/apicast/parameters/jaeger/test_open_telemetry_apicast_integration.py +++ b/testsuite/tests/apicast/parameters/jaeger/test_open_telemetry_apicast_integration.py @@ -6,13 +6,13 @@ import backoff import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, APICAST_OPERATOR_VERSION # noqa # pylint: disable=unused-import +from testsuite import APICAST_OPERATOR_VERSION, TESTED_VERSION +from testsuite.capabilities import Capability from testsuite.gateways.apicast.operator import OperatorApicast from testsuite.gateways.apicast.system import SystemApicast from testsuite.utils import randomize -from testsuite.capabilities import Capability pytestmark = [pytest.mark.required_capabilities(Capability.JAEGER, Capability.CUSTOM_ENVIRONMENT)] @@ -26,7 +26,7 @@ marks=[ pytest.mark.disruptive, pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY), - pytest.mark.skipif("TESTED_VERSION < Version('2.14')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.14"), reason="TESTED_VERSION < Version('2.14')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-7735"), ], ), @@ -35,7 +35,9 @@ id="operator", marks=[ pytest.mark.required_capabilities(Capability.OCP4), - pytest.mark.skipif("APICAST_OPERATOR_VERSION < Version('0.8.0')"), + pytest.mark.skipif( + APICAST_OPERATOR_VERSION < Version("0.8.0"), reason="APICAST_OPERATOR_VERSION < Version('0.8.0')" + ), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-9539"), ], ), diff --git a/testsuite/tests/apicast/parameters/policies/custom_policy/conftest.py b/testsuite/tests/apicast/parameters/policies/custom_policy/conftest.py index 4c6deff24..444c855ea 100644 --- a/testsuite/tests/apicast/parameters/policies/custom_policy/conftest.py +++ b/testsuite/tests/apicast/parameters/policies/custom_policy/conftest.py @@ -2,14 +2,15 @@ import base64 from contextlib import ExitStack -import pytest + import backoff +import pytest from testsuite import rawobj from testsuite.capabilities import Capability from testsuite.gateways.apicast.operator import OperatorApicast from testsuite.gateways.apicast.system import SystemApicast -from testsuite.utils import generate_tail, custom_policy +from testsuite.utils import custom_policy, generate_tail SCALE_OPERATOR = "3scale operator" APICAST_OPERATOR = "APIcast operator" diff --git a/testsuite/tests/apicast/parameters/policies/test_content_caching_policy_parameters.py b/testsuite/tests/apicast/parameters/policies/test_content_caching_policy_parameters.py index cf4b88bcf..603122971 100644 --- a/testsuite/tests/apicast/parameters/policies/test_content_caching_policy_parameters.py +++ b/testsuite/tests/apicast/parameters/policies/test_content_caching_policy_parameters.py @@ -5,17 +5,17 @@ """ import time -from packaging.version import Version # noqa # pylint: disable=unused-import import pytest +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import -from testsuite.echoed_request import EchoedRequest +from testsuite import TESTED_VERSION, rawobj from testsuite.capabilities import Capability +from testsuite.echoed_request import EchoedRequest from testsuite.utils import blame, randomize pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.9')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')"), pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT), ] diff --git a/testsuite/tests/apicast/parameters/test_apicast_load_services.py b/testsuite/tests/apicast/parameters/test_apicast_load_services.py index 66a58967a..81b565500 100644 --- a/testsuite/tests/apicast/parameters/test_apicast_load_services.py +++ b/testsuite/tests/apicast/parameters/test_apicast_load_services.py @@ -1,11 +1,10 @@ """Tests that APICAST_LOAD_SERVICES_WHEN_NEEDED loads all mapping rules""" import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj from testsuite.capabilities import Capability - from testsuite.utils import blame pytestmark = [ @@ -30,7 +29,13 @@ def service(backends_mapping, custom_service, service_proxy_settings, lifecycle_ @pytest.mark.parametrize( - "load_service", [pytest.param(True, marks=pytest.mark.skipif("TESTED_VERSION < Version('2.13')")), False] + "load_service", + [ + pytest.param( + True, marks=pytest.mark.skipif(TESTED_VERSION < Version("2.13"), reason="TESTED_VERSION < Version('2.13')") + ), + False, + ], ) def test_mapping_rule_hit(api_client, staging_gateway, load_service): """Tests that the mapping rule is loaded and works correctly""" diff --git a/testsuite/tests/apicast/parameters/test_apicast_service_configuration_version.py b/testsuite/tests/apicast/parameters/test_apicast_service_configuration_version.py index 7244d5001..2a12d1b7f 100644 --- a/testsuite/tests/apicast/parameters/test_apicast_service_configuration_version.py +++ b/testsuite/tests/apicast/parameters/test_apicast_service_configuration_version.py @@ -6,9 +6,8 @@ import pytest - -from testsuite.capabilities import Capability from testsuite import rawobj +from testsuite.capabilities import Capability pytestmark = [ pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT), diff --git a/testsuite/tests/apicast/parameters/test_date_logging.py b/testsuite/tests/apicast/parameters/test_date_logging.py index 1e030767d..b23dcfc6f 100644 --- a/testsuite/tests/apicast/parameters/test_date_logging.py +++ b/testsuite/tests/apicast/parameters/test_date_logging.py @@ -5,16 +5,18 @@ from datetime import datetime, timezone import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION, APICAST_OPERATOR_VERSION # noqa # pylint: disable=unused-import +from testsuite import APICAST_OPERATOR_VERSION, TESTED_VERSION, rawobj from testsuite.capabilities import Capability pytestmark = [ pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6594"), pytest.mark.required_capabilities(Capability.LOGS), - pytest.mark.skipif("TESTED_VERSION < Version('2.12')"), - pytest.mark.skipif("APICAST_OPERATOR_VERSION < Version('0.6.0')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.12"), reason="TESTED_VERSION < Version('2.12')"), + pytest.mark.skipif( + APICAST_OPERATOR_VERSION < Version("0.6.0"), reason="APICAST_OPERATOR_VERSION < Version('0.6.0')" + ), ] diff --git a/testsuite/tests/apicast/parameters/test_modular_apicast.py b/testsuite/tests/apicast/parameters/test_modular_apicast.py index 22042b717..74e6c9e5c 100644 --- a/testsuite/tests/apicast/parameters/test_modular_apicast.py +++ b/testsuite/tests/apicast/parameters/test_modular_apicast.py @@ -11,7 +11,6 @@ import backoff import importlib_resources as resources import pytest - from openshift_client import OpenShiftPythonException from testsuite import rawobj diff --git a/testsuite/tests/apicast/parameters/test_policy_dependency.py b/testsuite/tests/apicast/parameters/test_policy_dependency.py index a1cc1b343..44afa106c 100644 --- a/testsuite/tests/apicast/parameters/test_policy_dependency.py +++ b/testsuite/tests/apicast/parameters/test_policy_dependency.py @@ -9,7 +9,6 @@ # pylint has problem with lxml for some reason from lxml import etree from lxml.etree import XMLSyntaxError - from openshift_client import OpenShiftPythonException from testsuite import rawobj diff --git a/testsuite/tests/apicast/parameters/test_proxy_config.py b/testsuite/tests/apicast/parameters/test_proxy_config.py index 502f4be36..d7ce378cd 100644 --- a/testsuite/tests/apicast/parameters/test_proxy_config.py +++ b/testsuite/tests/apicast/parameters/test_proxy_config.py @@ -3,16 +3,16 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj from testsuite.capabilities import Capability pytestmark = [ pytest.mark.sandbag, pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-8485"), - pytest.mark.skipif("TESTED_VERSION < Version('2.13')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.13"), reason="TESTED_VERSION < Version('2.13')"), ] diff --git a/testsuite/tests/apicast/parameters/test_threescale_config_file.py b/testsuite/tests/apicast/parameters/test_threescale_config_file.py index d39462d8f..9e6e4cebf 100644 --- a/testsuite/tests/apicast/parameters/test_threescale_config_file.py +++ b/testsuite/tests/apicast/parameters/test_threescale_config_file.py @@ -7,8 +7,8 @@ import pytest -from testsuite.capabilities import Capability from testsuite import rawobj +from testsuite.capabilities import Capability from testsuite.gateways.apicast.template import TemplateApicast from testsuite.utils import blame diff --git a/testsuite/tests/apicast/policy/batcher/test_batcher_policy_append.py b/testsuite/tests/apicast/policy/batcher/test_batcher_policy_append.py index 51a7a0141..7663a407e 100644 --- a/testsuite/tests/apicast/policy/batcher/test_batcher_policy_append.py +++ b/testsuite/tests/apicast/policy/batcher/test_batcher_policy_append.py @@ -3,7 +3,9 @@ """ from time import sleep + import pytest + from testsuite import rawobj BATCH_REPORT_SECONDS = 50 diff --git a/testsuite/tests/apicast/policy/batcher/test_batcher_policy_append_apiap.py b/testsuite/tests/apicast/policy/batcher/test_batcher_policy_append_apiap.py index 119035db9..e4a9c1b91 100644 --- a/testsuite/tests/apicast/policy/batcher/test_batcher_policy_append_apiap.py +++ b/testsuite/tests/apicast/policy/batcher/test_batcher_policy_append_apiap.py @@ -3,7 +3,9 @@ """ from time import sleep + import pytest + from testsuite import rawobj BATCH_REPORT_SECONDS = 50 diff --git a/testsuite/tests/apicast/policy/batcher/test_batcher_policy_mapping_rules.py b/testsuite/tests/apicast/policy/batcher/test_batcher_policy_mapping_rules.py index 055cbf712..129632af4 100644 --- a/testsuite/tests/apicast/policy/batcher/test_batcher_policy_mapping_rules.py +++ b/testsuite/tests/apicast/policy/batcher/test_batcher_policy_mapping_rules.py @@ -3,14 +3,15 @@ """ from time import sleep + import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj pytestmark = [ pytest.mark.nopersistence, - pytest.mark.skipif("TESTED_VERSION < Version('2.9')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-5513"), ] diff --git a/testsuite/tests/apicast/policy/batcher/test_batcher_policy_nonalphanum_metric.py b/testsuite/tests/apicast/policy/batcher/test_batcher_policy_nonalphanum_metric.py index c5410acc6..90d9f8671 100644 --- a/testsuite/tests/apicast/policy/batcher/test_batcher_policy_nonalphanum_metric.py +++ b/testsuite/tests/apicast/policy/batcher/test_batcher_policy_nonalphanum_metric.py @@ -4,13 +4,14 @@ """ from time import sleep + import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.10')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.10"), reason="TESTED_VERSION < Version('2.10')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-4913"), ] diff --git a/testsuite/tests/apicast/policy/batcher/test_batcher_policy_oidc.py b/testsuite/tests/apicast/policy/batcher/test_batcher_policy_oidc.py index f3a8d0380..38287921f 100644 --- a/testsuite/tests/apicast/policy/batcher/test_batcher_policy_oidc.py +++ b/testsuite/tests/apicast/policy/batcher/test_batcher_policy_oidc.py @@ -3,6 +3,7 @@ """ from time import sleep + import pytest from testsuite import rawobj diff --git a/testsuite/tests/apicast/policy/caching/combination/test_caching_batching_apicast_scale_allow_mode.py b/testsuite/tests/apicast/policy/caching/combination/test_caching_batching_apicast_scale_allow_mode.py index e40410eed..2c84a633a 100644 --- a/testsuite/tests/apicast/policy/caching/combination/test_caching_batching_apicast_scale_allow_mode.py +++ b/testsuite/tests/apicast/policy/caching/combination/test_caching_batching_apicast_scale_allow_mode.py @@ -5,13 +5,13 @@ from time import sleep import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj from testsuite.capabilities import Capability pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.9.1')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9.1"), reason="TESTED_VERSION < Version('2.9.1')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-5753"), pytest.mark.required_capabilities(Capability.SCALING), ] diff --git a/testsuite/tests/apicast/policy/caching/combination/test_caching_batching_resilient_mode.py b/testsuite/tests/apicast/policy/caching/combination/test_caching_batching_resilient_mode.py index 44ed283f1..b9f89ca56 100644 --- a/testsuite/tests/apicast/policy/caching/combination/test_caching_batching_resilient_mode.py +++ b/testsuite/tests/apicast/policy/caching/combination/test_caching_batching_resilient_mode.py @@ -3,13 +3,15 @@ """ from time import sleep + import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from packaging.version import Version + +from testsuite import TESTED_VERSION, rawobj from testsuite.capabilities import Capability pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.9.1')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9.1"), reason="TESTED_VERSION < Version('2.9.1')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-5753"), pytest.mark.required_capabilities(Capability.SCALING), ] diff --git a/testsuite/tests/apicast/policy/caching/combination/test_caching_batching_strict_mode.py b/testsuite/tests/apicast/policy/caching/combination/test_caching_batching_strict_mode.py index abe8f220d..b624e197c 100644 --- a/testsuite/tests/apicast/policy/caching/combination/test_caching_batching_strict_mode.py +++ b/testsuite/tests/apicast/policy/caching/combination/test_caching_batching_strict_mode.py @@ -5,13 +5,13 @@ from time import sleep import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj from testsuite.capabilities import Capability pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.9.1')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9.1"), reason="TESTED_VERSION < Version('2.9.1')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-5753"), pytest.mark.required_capabilities(Capability.SCALING), ] diff --git a/testsuite/tests/apicast/policy/caching/test_caching_type_change.py b/testsuite/tests/apicast/policy/caching/test_caching_type_change.py index adf8d2eed..4cbe7f6bc 100644 --- a/testsuite/tests/apicast/policy/caching/test_caching_type_change.py +++ b/testsuite/tests/apicast/policy/caching/test_caching_type_change.py @@ -4,15 +4,16 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from packaging.version import Version + +from testsuite import TESTED_VERSION, rawobj from testsuite.capabilities import Capability from testsuite.gateways import gateway from testsuite.gateways.apicast.selfmanaged import SelfManagedApicast from testsuite.utils import blame pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.disruptive, pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-4464"), ] diff --git a/testsuite/tests/apicast/policy/conditional/test_batcher_policy_mapping_rules.py b/testsuite/tests/apicast/policy/conditional/test_batcher_policy_mapping_rules.py index 4ec111e45..7e22c159f 100644 --- a/testsuite/tests/apicast/policy/conditional/test_batcher_policy_mapping_rules.py +++ b/testsuite/tests/apicast/policy/conditional/test_batcher_policy_mapping_rules.py @@ -3,14 +3,15 @@ """ from time import sleep + import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj pytestmark = [ pytest.mark.nopersistence, - pytest.mark.skipif("TESTED_VERSION < Version('2.16')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.16"), reason="TESTED_VERSION < Version('2.16')"), ] BATCH_REPORT_SECONDS = 50 diff --git a/testsuite/tests/apicast/policy/conditional/test_fuse_proxy_policy.py b/testsuite/tests/apicast/policy/conditional/test_fuse_proxy_policy.py index 48a53dbfc..ae4944e6a 100644 --- a/testsuite/tests/apicast/policy/conditional/test_fuse_proxy_policy.py +++ b/testsuite/tests/apicast/policy/conditional/test_fuse_proxy_policy.py @@ -6,15 +6,15 @@ """ import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj from testsuite.capabilities import Capability from testsuite.echoed_request import EchoedRequest from testsuite.utils import warn_and_skip pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.16')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.16"), reason="TESTED_VERSION < Version('2.16')"), pytest.mark.required_capabilities(Capability.NOFIPS), ] diff --git a/testsuite/tests/apicast/policy/conditional/test_on_failed.py b/testsuite/tests/apicast/policy/conditional/test_on_failed.py index ba251d8cd..396b6fbc0 100644 --- a/testsuite/tests/apicast/policy/conditional/test_on_failed.py +++ b/testsuite/tests/apicast/policy/conditional/test_on_failed.py @@ -1,12 +1,11 @@ "testing proper function of on_failed policy with conditional policy" -from packaging.version import Version # noqa # pylint: disable=unused-import - import pytest +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj -pytestmark = pytest.mark.skipif("TESTED_VERSION < Version('2.16')") +pytestmark = pytest.mark.skipif(TESTED_VERSION < Version("2.16"), reason="TESTED_VERSION < Version('2.16')") @pytest.fixture(scope="module") diff --git a/testsuite/tests/apicast/policy/conditional/test_retry.py b/testsuite/tests/apicast/policy/conditional/test_retry.py index 90f460ce3..451262fb1 100644 --- a/testsuite/tests/apicast/policy/conditional/test_retry.py +++ b/testsuite/tests/apicast/policy/conditional/test_retry.py @@ -1,17 +1,18 @@ "testing proper function of retry policy with conditional policy" -from packaging.version import Version # noqa # pylint: disable=unused-import - import pytest +from packaging.version import Version +from testsuite import TESTED_VERSION, rawobj from testsuite.capabilities import Capability -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import -from testsuite.utils import blame, generate_tail from testsuite.gateways import gateway from testsuite.gateways.apicast.template import TemplateApicast +from testsuite.utils import blame, generate_tail -pytestmark = pytest.mark.skipif("TESTED_VERSION < Version('2.16')") -pytestmark = pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT) +pytestmark = [ + pytest.mark.skipif(TESTED_VERSION < Version("2.16"), reason="TESTED_VERSION < Version('2.16')"), + pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT), +] @pytest.fixture(scope="module") diff --git a/testsuite/tests/apicast/policy/conditional/test_upstream_connection.py b/testsuite/tests/apicast/policy/conditional/test_upstream_connection.py index fdbbceaa6..766411b5c 100644 --- a/testsuite/tests/apicast/policy/conditional/test_upstream_connection.py +++ b/testsuite/tests/apicast/policy/conditional/test_upstream_connection.py @@ -1,13 +1,12 @@ "testing proper function of upstream test connection with conditional policy" -from packaging.version import Version # noqa # pylint: disable=unused-import - import pytest +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj from testsuite.utils import warn_and_skip -pytestmark = pytest.mark.skipif("TESTED_VERSION < Version('2.16')") +pytestmark = pytest.mark.skipif(TESTED_VERSION < Version("2.16"), reason="TESTED_VERSION < Version('2.16')") # https://github.com/3scale/apicast-cloud-hosted diff --git a/testsuite/tests/apicast/policy/content_caching/test_content_caching.py b/testsuite/tests/apicast/policy/content_caching/test_content_caching.py index 03b0086cb..3678f05a4 100644 --- a/testsuite/tests/apicast/policy/content_caching/test_content_caching.py +++ b/testsuite/tests/apicast/policy/content_caching/test_content_caching.py @@ -4,13 +4,14 @@ import time import uuid -from packaging.version import Version # noqa # pylint: disable=unused-import + import pytest +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj from testsuite.echoed_request import EchoedRequest -pytestmark = pytest.mark.skipif("TESTED_VERSION < Version('2.9')") +pytestmark = pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')") @pytest.fixture(scope="module") diff --git a/testsuite/tests/apicast/policy/content_caching/test_content_caching_apiap.py b/testsuite/tests/apicast/policy/content_caching/test_content_caching_apiap.py index d886ef8c7..4b3287cb6 100644 --- a/testsuite/tests/apicast/policy/content_caching/test_content_caching_apiap.py +++ b/testsuite/tests/apicast/policy/content_caching/test_content_caching_apiap.py @@ -2,14 +2,14 @@ Test valid content caching on product with multiple backends """ -from packaging.version import Version # noqa # pylint: disable=unused-import import pytest +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj from testsuite.echoed_request import EchoedRequest -from testsuite.utils import randomize, blame +from testsuite.utils import blame, randomize -pytestmark = pytest.mark.skipif("TESTED_VERSION < Version('2.9')") +pytestmark = pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')") @pytest.fixture(scope="module") diff --git a/testsuite/tests/apicast/policy/content_limits/test_payload_limits_request.py b/testsuite/tests/apicast/policy/content_limits/test_payload_limits_request.py index 22d7ad3e3..396456ec7 100644 --- a/testsuite/tests/apicast/policy/content_limits/test_payload_limits_request.py +++ b/testsuite/tests/apicast/policy/content_limits/test_payload_limits_request.py @@ -4,13 +4,13 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version +from testsuite import TESTED_VERSION, rawobj from testsuite.utils import random_string -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.10')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.10"), reason="TESTED_VERSION < Version('2.10')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-5244"), ] diff --git a/testsuite/tests/apicast/policy/content_limits/test_payload_limits_response.py b/testsuite/tests/apicast/policy/content_limits/test_payload_limits_response.py index c957372a0..4c6b13754 100644 --- a/testsuite/tests/apicast/policy/content_limits/test_payload_limits_response.py +++ b/testsuite/tests/apicast/policy/content_limits/test_payload_limits_response.py @@ -4,13 +4,13 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj pytestmark = [ + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-5244"), - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6736"), ] diff --git a/testsuite/tests/apicast/policy/content_limits/test_payload_limits_unlimited.py b/testsuite/tests/apicast/policy/content_limits/test_payload_limits_unlimited.py index 041475b5a..22ee9579b 100644 --- a/testsuite/tests/apicast/policy/content_limits/test_payload_limits_unlimited.py +++ b/testsuite/tests/apicast/policy/content_limits/test_payload_limits_unlimited.py @@ -4,13 +4,13 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version +from testsuite import TESTED_VERSION, rawobj from testsuite.utils import random_string -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.10')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.10"), reason="TESTED_VERSION < Version('2.10')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-5244"), ] diff --git a/testsuite/tests/apicast/policy/cors/test_cors_max_age.py b/testsuite/tests/apicast/policy/cors/test_cors_max_age.py index 5b879309d..c67d7dcd2 100644 --- a/testsuite/tests/apicast/policy/cors/test_cors_max_age.py +++ b/testsuite/tests/apicast/policy/cors/test_cors_max_age.py @@ -3,6 +3,7 @@ """ import pytest + from testsuite import rawobj diff --git a/testsuite/tests/apicast/policy/cors/test_cors_multiple_origins.py b/testsuite/tests/apicast/policy/cors/test_cors_multiple_origins.py index aa8c4e84b..166d34cf7 100644 --- a/testsuite/tests/apicast/policy/cors/test_cors_multiple_origins.py +++ b/testsuite/tests/apicast/policy/cors/test_cors_multiple_origins.py @@ -6,13 +6,12 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import -from testsuite import rawobj +from testsuite import TESTED_VERSION, rawobj pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.10')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.10"), reason="TESTED_VERSION < Version('2.10')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6569"), ] diff --git a/testsuite/tests/apicast/policy/cors/test_cors_policy.py b/testsuite/tests/apicast/policy/cors/test_cors_policy.py index 274bcbc13..38517f6b4 100644 --- a/testsuite/tests/apicast/policy/cors/test_cors_policy.py +++ b/testsuite/tests/apicast/policy/cors/test_cors_policy.py @@ -4,9 +4,10 @@ Rewrite: ./spec/functional_specs/policies/cors/cors_policy_spec.rb """ -from packaging.version import Version import pytest -from testsuite import rawobj, TESTED_VERSION +from packaging.version import Version + +from testsuite import TESTED_VERSION, rawobj @pytest.fixture(scope="module") diff --git a/testsuite/tests/apicast/policy/custom_metric/config_cases.py b/testsuite/tests/apicast/policy/custom_metric/config_cases.py index 56a7e86e4..52ae7cd5a 100644 --- a/testsuite/tests/apicast/policy/custom_metric/config_cases.py +++ b/testsuite/tests/apicast/policy/custom_metric/config_cases.py @@ -3,7 +3,8 @@ This file contains different cases for testing. """ -from typing import Tuple, List +from typing import List, Tuple + from testsuite import rawobj diff --git a/testsuite/tests/apicast/policy/custom_metric/test_custom_metric_policy_parametrized.py b/testsuite/tests/apicast/policy/custom_metric/test_custom_metric_policy_parametrized.py index 6695191ca..169d85369 100644 --- a/testsuite/tests/apicast/policy/custom_metric/test_custom_metric_policy_parametrized.py +++ b/testsuite/tests/apicast/policy/custom_metric/test_custom_metric_policy_parametrized.py @@ -6,16 +6,16 @@ import pytest import pytest_cases -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version from pytest_cases import parametrize_with_cases +from testsuite import TESTED_VERSION, rawobj, resilient from testsuite.tests.apicast.policy.custom_metric import config_cases from testsuite.utils import blame -from testsuite import rawobj, resilient, TESTED_VERSION # noqa # pylint: disable=unused-import pytestmark = [ pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-5098"), - pytest.mark.skipif("TESTED_VERSION < Version('2.9')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')"), ] diff --git a/testsuite/tests/apicast/policy/fapi/test_baseline_profile.py b/testsuite/tests/apicast/policy/fapi/test_baseline_profile.py index 255035d6e..d805600e0 100644 --- a/testsuite/tests/apicast/policy/fapi/test_baseline_profile.py +++ b/testsuite/tests/apicast/policy/fapi/test_baseline_profile.py @@ -8,10 +8,10 @@ import pytest import threescale_api - from packaging.version import Version -from testsuite.utils import blame + from testsuite import TESTED_VERSION, rawobj +from testsuite.utils import blame pytestmark = pytest.mark.skipif(TESTED_VERSION < Version("2.16.2"), reason="Threescale version must be at least 2.16.2") diff --git a/testsuite/tests/apicast/policy/headers/test_headers_policy_add.py b/testsuite/tests/apicast/policy/headers/test_headers_policy_add.py index 17ca5b6d5..809508c67 100644 --- a/testsuite/tests/apicast/policy/headers/test_headers_policy_add.py +++ b/testsuite/tests/apicast/policy/headers/test_headers_policy_add.py @@ -3,6 +3,7 @@ """ import pytest + from testsuite import rawobj from testsuite.echoed_request import EchoedRequest diff --git a/testsuite/tests/apicast/policy/headers/test_headers_policy_add_apiap.py b/testsuite/tests/apicast/policy/headers/test_headers_policy_add_apiap.py index d0118df44..3b75b23dc 100644 --- a/testsuite/tests/apicast/policy/headers/test_headers_policy_add_apiap.py +++ b/testsuite/tests/apicast/policy/headers/test_headers_policy_add_apiap.py @@ -3,6 +3,7 @@ """ import pytest + from testsuite import rawobj from testsuite.echoed_request import EchoedRequest diff --git a/testsuite/tests/apicast/policy/headers/test_headers_policy_delete.py b/testsuite/tests/apicast/policy/headers/test_headers_policy_delete.py index 75b39f94a..4dc04d48a 100644 --- a/testsuite/tests/apicast/policy/headers/test_headers_policy_delete.py +++ b/testsuite/tests/apicast/policy/headers/test_headers_policy_delete.py @@ -3,6 +3,7 @@ """ import pytest + from testsuite import rawobj from testsuite.echoed_request import EchoedRequest diff --git a/testsuite/tests/apicast/policy/headers/test_headers_policy_jwt.py b/testsuite/tests/apicast/policy/headers/test_headers_policy_jwt.py index 66bed245b..ad2f4514f 100644 --- a/testsuite/tests/apicast/policy/headers/test_headers_policy_jwt.py +++ b/testsuite/tests/apicast/policy/headers/test_headers_policy_jwt.py @@ -7,11 +7,12 @@ """ import time + import pytest from testsuite import rawobj -from testsuite.rhsso.rhsso import OIDCClientAuthHook from testsuite.echoed_request import EchoedRequest +from testsuite.rhsso.rhsso import OIDCClientAuthHook @pytest.fixture(scope="module", autouse=True) diff --git a/testsuite/tests/apicast/policy/headers/test_headers_policy_liquid_set.py b/testsuite/tests/apicast/policy/headers/test_headers_policy_liquid_set.py index c11978bdd..e68900353 100644 --- a/testsuite/tests/apicast/policy/headers/test_headers_policy_liquid_set.py +++ b/testsuite/tests/apicast/policy/headers/test_headers_policy_liquid_set.py @@ -5,6 +5,7 @@ """ import pytest + from testsuite import rawobj from testsuite.echoed_request import EchoedRequest diff --git a/testsuite/tests/apicast/policy/ip_check/test_ip_check_policy_forward_ip_whitelist.py b/testsuite/tests/apicast/policy/ip_check/test_ip_check_policy_forward_ip_whitelist.py index 7003a3501..a5a6271c4 100644 --- a/testsuite/tests/apicast/policy/ip_check/test_ip_check_policy_forward_ip_whitelist.py +++ b/testsuite/tests/apicast/policy/ip_check/test_ip_check_policy_forward_ip_whitelist.py @@ -2,11 +2,10 @@ Rewrite spec/functional_specs/policies/ip_check/ip_check_forward_whitelist_spec.rb """ -from packaging.version import Version # noqa # pylint: disable=unused-import - import pytest +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj pytestmark = [pytest.mark.nopersistence] @@ -35,7 +34,7 @@ def test_ip_check_policy_ip_blacklisted(api_client): 403, marks=[ pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-7076"), - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), ], ), pytest.param( @@ -43,7 +42,7 @@ def test_ip_check_policy_ip_blacklisted(api_client): 403, marks=[ pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-7075"), - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), ], ), ], diff --git a/testsuite/tests/apicast/policy/ip_check/test_ip_check_policy_real_ip_whitelist.py b/testsuite/tests/apicast/policy/ip_check/test_ip_check_policy_real_ip_whitelist.py index 7f39848b1..a589ed57e 100644 --- a/testsuite/tests/apicast/policy/ip_check/test_ip_check_policy_real_ip_whitelist.py +++ b/testsuite/tests/apicast/policy/ip_check/test_ip_check_policy_real_ip_whitelist.py @@ -3,6 +3,7 @@ """ import pytest + from testsuite import rawobj pytestmark = [pytest.mark.nopersistence] diff --git a/testsuite/tests/apicast/policy/jwt_claim_check/test_jwt_claim_check_backend_routing.py b/testsuite/tests/apicast/policy/jwt_claim_check/test_jwt_claim_check_backend_routing.py index 533407d3f..c8a6d3d1b 100644 --- a/testsuite/tests/apicast/policy/jwt_claim_check/test_jwt_claim_check_backend_routing.py +++ b/testsuite/tests/apicast/policy/jwt_claim_check/test_jwt_claim_check_backend_routing.py @@ -4,13 +4,12 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import -from testsuite import rawobj +from testsuite import TESTED_VERSION, rawobj pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6410"), ] diff --git a/testsuite/tests/apicast/policy/keycloak_role_check/conftest.py b/testsuite/tests/apicast/policy/keycloak_role_check/conftest.py index 3a4b3fc5c..2ff898101 100644 --- a/testsuite/tests/apicast/policy/keycloak_role_check/conftest.py +++ b/testsuite/tests/apicast/policy/keycloak_role_check/conftest.py @@ -6,7 +6,7 @@ from testsuite import rawobj from testsuite.rhsso.rhsso import OIDCClientAuthHook -from testsuite.utils import randomize, blame +from testsuite.utils import blame, randomize # pylint: disable=unused-argument, too-many-arguments diff --git a/testsuite/tests/apicast/policy/keycloak_role_check/test_keycloak_policy.py b/testsuite/tests/apicast/policy/keycloak_role_check/test_keycloak_policy.py index 22753525b..3e2d250a7 100644 --- a/testsuite/tests/apicast/policy/keycloak_role_check/test_keycloak_policy.py +++ b/testsuite/tests/apicast/policy/keycloak_role_check/test_keycloak_policy.py @@ -16,6 +16,7 @@ from testsuite import rawobj from testsuite.capabilities import Capability + from .conftest import token pytestmark = [pytest.mark.disruptive, pytest.mark.required_capabilities(Capability.PRODUCTION_GATEWAY)] diff --git a/testsuite/tests/apicast/policy/keycloak_role_check/test_keycloak_policy_combined.py b/testsuite/tests/apicast/policy/keycloak_role_check/test_keycloak_policy_combined.py index 63cb07873..2c1617881 100644 --- a/testsuite/tests/apicast/policy/keycloak_role_check/test_keycloak_policy_combined.py +++ b/testsuite/tests/apicast/policy/keycloak_role_check/test_keycloak_policy_combined.py @@ -13,6 +13,7 @@ from testsuite import rawobj from testsuite.capabilities import Capability from testsuite.utils import randomize + from .conftest import token pytestmark = [pytest.mark.disruptive, pytest.mark.required_capabilities(Capability.PRODUCTION_GATEWAY)] diff --git a/testsuite/tests/apicast/policy/liquid_context_debug/test_debug_policy_apiap.py b/testsuite/tests/apicast/policy/liquid_context_debug/test_debug_policy_apiap.py index cd41e1b8c..b19fce77f 100644 --- a/testsuite/tests/apicast/policy/liquid_context_debug/test_debug_policy_apiap.py +++ b/testsuite/tests/apicast/policy/liquid_context_debug/test_debug_policy_apiap.py @@ -6,12 +6,12 @@ from urllib.parse import urlparse import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6312"), ] diff --git a/testsuite/tests/apicast/policy/logging/conftest.py b/testsuite/tests/apicast/policy/logging/conftest.py index 16108663a..8364a271a 100644 --- a/testsuite/tests/apicast/policy/logging/conftest.py +++ b/testsuite/tests/apicast/policy/logging/conftest.py @@ -1,7 +1,7 @@ """logging policy tests shared fixtures""" -from weakget import weakget import pytest +from weakget import weakget from testsuite.utils import warn_and_skip diff --git a/testsuite/tests/apicast/policy/logging/test_logging_condition.py b/testsuite/tests/apicast/policy/logging/test_logging_condition.py index a74e995f5..4444be477 100644 --- a/testsuite/tests/apicast/policy/logging/test_logging_condition.py +++ b/testsuite/tests/apicast/policy/logging/test_logging_condition.py @@ -4,6 +4,7 @@ """ import pytest + from testsuite import rawobj from testsuite.capabilities import Capability from testsuite.utils import randomize diff --git a/testsuite/tests/apicast/policy/logging/test_logging_disabled.py b/testsuite/tests/apicast/policy/logging/test_logging_disabled.py index 4db3f166c..27a7f7819 100644 --- a/testsuite/tests/apicast/policy/logging/test_logging_disabled.py +++ b/testsuite/tests/apicast/policy/logging/test_logging_disabled.py @@ -3,6 +3,7 @@ """ import pytest + from testsuite import rawobj from testsuite.capabilities import Capability from testsuite.utils import randomize diff --git a/testsuite/tests/apicast/policy/logging/test_logging_enabled.py b/testsuite/tests/apicast/policy/logging/test_logging_enabled.py index a9c29db57..1b573edc1 100644 --- a/testsuite/tests/apicast/policy/logging/test_logging_enabled.py +++ b/testsuite/tests/apicast/policy/logging/test_logging_enabled.py @@ -3,6 +3,7 @@ """ import pytest + from testsuite import rawobj from testsuite.capabilities import Capability from testsuite.utils import randomize diff --git a/testsuite/tests/apicast/policy/maintenance_mode/conftest.py b/testsuite/tests/apicast/policy/maintenance_mode/conftest.py index 843b40cf7..1d3fc2dce 100644 --- a/testsuite/tests/apicast/policy/maintenance_mode/conftest.py +++ b/testsuite/tests/apicast/policy/maintenance_mode/conftest.py @@ -1,12 +1,11 @@ "Provides custom service to add policy to policy chain" import pytest - import pytest_cases from testsuite import rawobj -from testsuite.utils import blame from testsuite.capabilities import Capability +from testsuite.utils import blame pytestmark = [ pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY), diff --git a/testsuite/tests/apicast/policy/maintenance_mode/test_maintenance_mode_policy_host.py b/testsuite/tests/apicast/policy/maintenance_mode/test_maintenance_mode_policy_host.py index 4588b43c7..d2d87960d 100644 --- a/testsuite/tests/apicast/policy/maintenance_mode/test_maintenance_mode_policy_host.py +++ b/testsuite/tests/apicast/policy/maintenance_mode/test_maintenance_mode_policy_host.py @@ -9,14 +9,13 @@ import pytest import pytest_cases +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import - -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj from testsuite.tests.apicast.policy.maintenance_mode import config_cases_host pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6552"), ] diff --git a/testsuite/tests/apicast/policy/maintenance_mode/test_maintenance_mode_policy_path.py b/testsuite/tests/apicast/policy/maintenance_mode/test_maintenance_mode_policy_path.py index a60fe8ab2..31749840e 100644 --- a/testsuite/tests/apicast/policy/maintenance_mode/test_maintenance_mode_policy_path.py +++ b/testsuite/tests/apicast/policy/maintenance_mode/test_maintenance_mode_policy_path.py @@ -8,14 +8,13 @@ import pytest import pytest_cases +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import - -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj from testsuite.tests.apicast.policy.maintenance_mode import config_cases_path pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6552"), ] diff --git a/testsuite/tests/apicast/policy/nginx_filter/test_nginx_filter_ngnix_blocking.py b/testsuite/tests/apicast/policy/nginx_filter/test_nginx_filter_ngnix_blocking.py index 7d556cafb..bfdbf49be 100644 --- a/testsuite/tests/apicast/policy/nginx_filter/test_nginx_filter_ngnix_blocking.py +++ b/testsuite/tests/apicast/policy/nginx_filter/test_nginx_filter_ngnix_blocking.py @@ -5,14 +5,14 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version from weakget import weakget -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj from testsuite.utils import blame, warn_and_skip pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6704"), ] diff --git a/testsuite/tests/apicast/policy/nginx_filter/test_nginx_filter_strip_if_match.py b/testsuite/tests/apicast/policy/nginx_filter/test_nginx_filter_strip_if_match.py index b259f596c..8147dba61 100644 --- a/testsuite/tests/apicast/policy/nginx_filter/test_nginx_filter_strip_if_match.py +++ b/testsuite/tests/apicast/policy/nginx_filter/test_nginx_filter_strip_if_match.py @@ -4,14 +4,14 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj from testsuite.capabilities import Capability from testsuite.echoed_request import EchoedRequest pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6704"), pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT), ] diff --git a/testsuite/tests/apicast/policy/on_failed/test_onfailed_custom_policy.py b/testsuite/tests/apicast/policy/on_failed/test_onfailed_custom_policy.py index 0c3ad4d20..9526ed938 100644 --- a/testsuite/tests/apicast/policy/on_failed/test_onfailed_custom_policy.py +++ b/testsuite/tests/apicast/policy/on_failed/test_onfailed_custom_policy.py @@ -6,7 +6,6 @@ import backoff import importlib_resources as resources import pytest - from openshift_client import OpenShiftPythonException from testsuite.capabilities import Capability diff --git a/testsuite/tests/apicast/policy/rate_limit/conftest.py b/testsuite/tests/apicast/policy/rate_limit/conftest.py index 263c0f71d..fb0175211 100644 --- a/testsuite/tests/apicast/policy/rate_limit/conftest.py +++ b/testsuite/tests/apicast/policy/rate_limit/conftest.py @@ -3,6 +3,7 @@ """ import warnings + import pytest import pytest_cases import threescale_api.errors diff --git a/testsuite/tests/apicast/policy/rate_limit/fixed_window/test_fixed_window_policy.py b/testsuite/tests/apicast/policy/rate_limit/fixed_window/test_fixed_window_policy.py index c53d5b4fc..e63761ffb 100644 --- a/testsuite/tests/apicast/policy/rate_limit/fixed_window/test_fixed_window_policy.py +++ b/testsuite/tests/apicast/policy/rate_limit/fixed_window/test_fixed_window_policy.py @@ -18,10 +18,12 @@ """ import time + import backoff import pytest import pytest_cases from pytest_cases import parametrize_with_cases + from testsuite import rawobj from testsuite.capabilities import Capability from testsuite.tests.apicast.policy.rate_limit.fixed_window import config_cases diff --git a/testsuite/tests/apicast/policy/rate_limit/test_rate_limit_connection.py b/testsuite/tests/apicast/policy/rate_limit/test_rate_limit_connection.py index c00224d4a..4eb9e8ae4 100644 --- a/testsuite/tests/apicast/policy/rate_limit/test_rate_limit_connection.py +++ b/testsuite/tests/apicast/policy/rate_limit/test_rate_limit_connection.py @@ -24,17 +24,17 @@ spec/functional_specs/policies/rate_limit/connection/plain_text/true_condition/rate_limit_connection_service_true_spec.rb """ -from datetime import datetime, timedelta, timezone -from pprint import pformat import asyncio import random +from datetime import datetime, timedelta, timezone +from pprint import pformat import httpx import pytest from testsuite import rawobj from testsuite.httpx import AsyncClientHook -from testsuite.utils import randomize, blame +from testsuite.utils import blame, randomize # the results can be bit unstable due to higher load caused by parallel # http requests diff --git a/testsuite/tests/apicast/policy/rate_limit_headers/conftest.py b/testsuite/tests/apicast/policy/rate_limit_headers/conftest.py index bbd5cbfa4..6e4754f4e 100644 --- a/testsuite/tests/apicast/policy/rate_limit_headers/conftest.py +++ b/testsuite/tests/apicast/policy/rate_limit_headers/conftest.py @@ -3,6 +3,7 @@ """ import pytest + from testsuite import rawobj from testsuite.utils import blame diff --git a/testsuite/tests/apicast/policy/rate_limit_headers/test_rate_limit_headers.py b/testsuite/tests/apicast/policy/rate_limit_headers/test_rate_limit_headers.py index dc874c614..76ccf3b50 100644 --- a/testsuite/tests/apicast/policy/rate_limit_headers/test_rate_limit_headers.py +++ b/testsuite/tests/apicast/policy/rate_limit_headers/test_rate_limit_headers.py @@ -6,19 +6,18 @@ - the combination of backend and service metrics should make no problem """ -from packaging.version import Version # noqa # pylint: disable=unused-import import pytest import pytest_cases +from packaging.version import Version from pytest_cases import fixture_ref +from testsuite import TESTED_VERSION, rawobj from testsuite.utils import blame, wait_interval -from testsuite import rawobj -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import # rate-limit have been always unstable, likely because of overhead in staging apicast? pytestmark = [ pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-3795"), - pytest.mark.skipif("TESTED_VERSION < Version('2.9')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')"), pytest.mark.flaky, ] diff --git a/testsuite/tests/apicast/policy/rate_limit_headers/test_rate_limit_headers_multiple_limits.py b/testsuite/tests/apicast/policy/rate_limit_headers/test_rate_limit_headers_multiple_limits.py index 9c6625079..4bcb1688e 100644 --- a/testsuite/tests/apicast/policy/rate_limit_headers/test_rate_limit_headers_multiple_limits.py +++ b/testsuite/tests/apicast/policy/rate_limit_headers/test_rate_limit_headers_multiple_limits.py @@ -3,16 +3,21 @@ the currently more constrained limit are sent. """ -from packaging.version import Version # noqa # pylint: disable=unused-import import pytest -from testsuite.utils import blame, wait_interval, wait_until_next_minute, wait_interval_hour -from testsuite import rawobj -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from packaging.version import Version + +from testsuite import TESTED_VERSION, rawobj +from testsuite.utils import ( + blame, + wait_interval, + wait_interval_hour, + wait_until_next_minute, +) # rate-limit have been always unstable, likely because of overhead in staging apicast? pytestmark = [ pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-3795"), - pytest.mark.skipif("TESTED_VERSION < Version('2.9')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')"), pytest.mark.flaky, ] diff --git a/testsuite/tests/apicast/policy/rate_limit_headers/test_rate_limit_headers_no_limit.py b/testsuite/tests/apicast/policy/rate_limit_headers/test_rate_limit_headers_no_limit.py index 6eef248fb..d42925fe2 100644 --- a/testsuite/tests/apicast/policy/rate_limit_headers/test_rate_limit_headers_no_limit.py +++ b/testsuite/tests/apicast/policy/rate_limit_headers/test_rate_limit_headers_no_limit.py @@ -2,14 +2,17 @@ When no limit is specified, the RateLimit headers should not be contained in the response """ -from packaging.version import Version # noqa # pylint: disable=unused-import import pytest +from packaging.version import Version + +from testsuite import TESTED_VERSION, rawobj from testsuite.utils import blame -from testsuite import rawobj -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import # rate-limit have been always unstable, likely because of overhead in staging apicast? -pytestmark = [pytest.mark.skipif("TESTED_VERSION < Version('2.9')"), pytest.mark.flaky] +pytestmark = [ + pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')"), + pytest.mark.flaky, +] @pytest.fixture(scope="module") diff --git a/testsuite/tests/apicast/policy/rate_limit_headers/test_rate_limit_with_batcher_policy.py b/testsuite/tests/apicast/policy/rate_limit_headers/test_rate_limit_with_batcher_policy.py index 988c0b1f1..5cf9ce2f2 100644 --- a/testsuite/tests/apicast/policy/rate_limit_headers/test_rate_limit_with_batcher_policy.py +++ b/testsuite/tests/apicast/policy/rate_limit_headers/test_rate_limit_with_batcher_policy.py @@ -3,16 +3,17 @@ """ import time -from packaging.version import Version # noqa # pylint: disable=unused-import + import pytest +from packaging.version import Version + +from testsuite import TESTED_VERSION, rawobj from testsuite.utils import blame, wait_interval -from testsuite import rawobj -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import # rate-limit have been always unstable, likely because of overhead in staging apicast? pytestmark = [ pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-3795"), - pytest.mark.skipif("TESTED_VERSION < Version('2.9')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')"), pytest.mark.flaky, ] diff --git a/testsuite/tests/apicast/policy/retry_policy/conftest.py b/testsuite/tests/apicast/policy/retry_policy/conftest.py index 4d737f06b..e3e97f325 100644 --- a/testsuite/tests/apicast/policy/retry_policy/conftest.py +++ b/testsuite/tests/apicast/policy/retry_policy/conftest.py @@ -5,8 +5,7 @@ from testsuite.gateways import gateway from testsuite.gateways.apicast.template import TemplateApicast -from testsuite.utils import blame -from testsuite.utils import warn_and_skip +from testsuite.utils import blame, warn_and_skip @pytest.fixture(scope="module", autouse=True) diff --git a/testsuite/tests/apicast/policy/retry_policy/test_retry_policy.py b/testsuite/tests/apicast/policy/retry_policy/test_retry_policy.py index 5a5169316..935b5ef04 100644 --- a/testsuite/tests/apicast/policy/retry_policy/test_retry_policy.py +++ b/testsuite/tests/apicast/policy/retry_policy/test_retry_policy.py @@ -10,6 +10,7 @@ """ import pytest + from testsuite import rawobj from testsuite.capabilities import Capability from testsuite.mockserver import Mockserver diff --git a/testsuite/tests/apicast/policy/routing/test_routing_policy_catch_all.py b/testsuite/tests/apicast/policy/routing/test_routing_policy_catch_all.py index 4ca364e29..cf06b4309 100644 --- a/testsuite/tests/apicast/policy/routing/test_routing_policy_catch_all.py +++ b/testsuite/tests/apicast/policy/routing/test_routing_policy_catch_all.py @@ -4,14 +4,15 @@ """ from urllib.parse import urlparse + import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj from testsuite.echoed_request import EchoedRequest pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6415"), ] diff --git a/testsuite/tests/apicast/policy/routing/test_routing_policy_headers.py b/testsuite/tests/apicast/policy/routing/test_routing_policy_headers.py index b406d419a..97235868a 100644 --- a/testsuite/tests/apicast/policy/routing/test_routing_policy_headers.py +++ b/testsuite/tests/apicast/policy/routing/test_routing_policy_headers.py @@ -3,6 +3,7 @@ """ from urllib.parse import urlparse + import pytest from testsuite.echoed_request import EchoedRequest diff --git a/testsuite/tests/apicast/policy/routing/test_routing_policy_jwt.py b/testsuite/tests/apicast/policy/routing/test_routing_policy_jwt.py index 8063d9cd9..4c0ebdad1 100644 --- a/testsuite/tests/apicast/policy/routing/test_routing_policy_jwt.py +++ b/testsuite/tests/apicast/policy/routing/test_routing_policy_jwt.py @@ -5,9 +5,10 @@ from urllib.parse import urlparse import pytest + from testsuite import rawobj -from testsuite.rhsso.rhsso import OIDCClientAuthHook from testsuite.echoed_request import EchoedRequest +from testsuite.rhsso.rhsso import OIDCClientAuthHook from testsuite.utils import blame diff --git a/testsuite/tests/apicast/policy/routing/test_routing_policy_multiple_conditions_and.py b/testsuite/tests/apicast/policy/routing/test_routing_policy_multiple_conditions_and.py index 01dceeb4c..fd91f3c37 100644 --- a/testsuite/tests/apicast/policy/routing/test_routing_policy_multiple_conditions_and.py +++ b/testsuite/tests/apicast/policy/routing/test_routing_policy_multiple_conditions_and.py @@ -3,6 +3,7 @@ """ from urllib.parse import urlparse + import pytest from testsuite.echoed_request import EchoedRequest diff --git a/testsuite/tests/apicast/policy/routing/test_routing_policy_multiple_conditions_or.py b/testsuite/tests/apicast/policy/routing/test_routing_policy_multiple_conditions_or.py index a14905cde..013d6c6e7 100644 --- a/testsuite/tests/apicast/policy/routing/test_routing_policy_multiple_conditions_or.py +++ b/testsuite/tests/apicast/policy/routing/test_routing_policy_multiple_conditions_or.py @@ -3,7 +3,9 @@ """ from urllib.parse import urlparse + import pytest + from testsuite import rawobj from testsuite.echoed_request import EchoedRequest diff --git a/testsuite/tests/apicast/policy/routing/test_routing_policy_path.py b/testsuite/tests/apicast/policy/routing/test_routing_policy_path.py index 692d9fc1d..5d9f72a8b 100644 --- a/testsuite/tests/apicast/policy/routing/test_routing_policy_path.py +++ b/testsuite/tests/apicast/policy/routing/test_routing_policy_path.py @@ -6,6 +6,7 @@ from urllib.parse import urlsplit, urlunsplit import pytest + from testsuite.echoed_request import EchoedRequest diff --git a/testsuite/tests/apicast/policy/routing/test_routing_policy_query.py b/testsuite/tests/apicast/policy/routing/test_routing_policy_query.py index 181b04094..e001bace9 100644 --- a/testsuite/tests/apicast/policy/routing/test_routing_policy_query.py +++ b/testsuite/tests/apicast/policy/routing/test_routing_policy_query.py @@ -3,6 +3,7 @@ """ from urllib.parse import urlparse + import pytest from testsuite.echoed_request import EchoedRequest diff --git a/testsuite/tests/apicast/policy/routing/test_routing_policy_replace_path.py b/testsuite/tests/apicast/policy/routing/test_routing_policy_replace_path.py index 6cb254a56..4990d84f8 100644 --- a/testsuite/tests/apicast/policy/routing/test_routing_policy_replace_path.py +++ b/testsuite/tests/apicast/policy/routing/test_routing_policy_replace_path.py @@ -3,6 +3,7 @@ """ import pytest + from testsuite import rawobj from testsuite.echoed_request import EchoedRequest diff --git a/testsuite/tests/apicast/policy/soap/test_soap_policy.py b/testsuite/tests/apicast/policy/soap/test_soap_policy.py index 6d35f527d..15ce9a24d 100644 --- a/testsuite/tests/apicast/policy/soap/test_soap_policy.py +++ b/testsuite/tests/apicast/policy/soap/test_soap_policy.py @@ -3,8 +3,8 @@ """ import pytest -from testsuite import rawobj -from testsuite import resilient + +from testsuite import rawobj, resilient @pytest.fixture(scope="module") diff --git a/testsuite/tests/apicast/policy/statuscode_overwrite/test_statuscode_overwrite_payload_too_large_before.py b/testsuite/tests/apicast/policy/statuscode_overwrite/test_statuscode_overwrite_payload_too_large_before.py index 3185b3853..85decbbc9 100644 --- a/testsuite/tests/apicast/policy/statuscode_overwrite/test_statuscode_overwrite_payload_too_large_before.py +++ b/testsuite/tests/apicast/policy/statuscode_overwrite/test_statuscode_overwrite_payload_too_large_before.py @@ -6,11 +6,12 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from packaging.version import Version + +from testsuite import TESTED_VERSION, rawobj pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6255"), ] diff --git a/testsuite/tests/apicast/policy/statuscode_overwrite/test_statuscode_overwrite_payoad_too_large_after.py b/testsuite/tests/apicast/policy/statuscode_overwrite/test_statuscode_overwrite_payoad_too_large_after.py index 8949a76aa..86fbd6fb5 100644 --- a/testsuite/tests/apicast/policy/statuscode_overwrite/test_statuscode_overwrite_payoad_too_large_after.py +++ b/testsuite/tests/apicast/policy/statuscode_overwrite/test_statuscode_overwrite_payoad_too_large_after.py @@ -6,11 +6,12 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from packaging.version import Version + +from testsuite import TESTED_VERSION, rawobj pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6255"), ] diff --git a/testsuite/tests/apicast/policy/statuscode_overwrite/test_statuscode_overwrite_policy.py b/testsuite/tests/apicast/policy/statuscode_overwrite/test_statuscode_overwrite_policy.py index b33c18ba0..f0598a846 100644 --- a/testsuite/tests/apicast/policy/statuscode_overwrite/test_statuscode_overwrite_policy.py +++ b/testsuite/tests/apicast/policy/statuscode_overwrite/test_statuscode_overwrite_policy.py @@ -4,11 +4,12 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from packaging.version import Version + +from testsuite import TESTED_VERSION, rawobj pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6255"), ] diff --git a/testsuite/tests/apicast/policy/test_default_credentials_policy.py b/testsuite/tests/apicast/policy/test_default_credentials_policy.py index c8290c44c..80c20b7b9 100644 --- a/testsuite/tests/apicast/policy/test_default_credentials_policy.py +++ b/testsuite/tests/apicast/policy/test_default_credentials_policy.py @@ -1,7 +1,6 @@ "Rewrite spec/functional_specs/policies/default_credentials_spec.rb" import pytest - from threescale_api.resources import Service from testsuite import rawobj diff --git a/testsuite/tests/apicast/policy/test_liquid.py b/testsuite/tests/apicast/policy/test_liquid.py index 132f14686..e4422d254 100644 --- a/testsuite/tests/apicast/policy/test_liquid.py +++ b/testsuite/tests/apicast/policy/test_liquid.py @@ -2,15 +2,13 @@ Test behavior of liquid """ -from packaging.version import Version # noqa # pylint: disable=unused-import - import pytest +from packaging.version import Version -from testsuite import rawobj -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj pytestmark = [ - pytest.mark.skipif("TESTED_VERSION <= Version('2.13')"), + pytest.mark.skipif(TESTED_VERSION <= Version("2.13"), reason="TESTED_VERSION <= Version('2.13')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-8483"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-8484"), ] diff --git a/testsuite/tests/apicast/policy/test_long_policy_chain.py b/testsuite/tests/apicast/policy/test_long_policy_chain.py index 6fcd865c0..3bdd3b5de 100644 --- a/testsuite/tests/apicast/policy/test_long_policy_chain.py +++ b/testsuite/tests/apicast/policy/test_long_policy_chain.py @@ -1,10 +1,9 @@ """Test for large policy chain""" import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import - -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj @pytest.fixture() @@ -14,7 +13,7 @@ def policy(): @pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-8377") -@pytest.mark.skipif("TESTED_VERSION < Version('2.14-dev')") +@pytest.mark.skipif(TESTED_VERSION < Version("2.14-dev"), reason="TESTED_VERSION < Version('2.14-dev')") def test_long_policy_chain(policy, service): """ Test creates a policy chain with size greater than 65,535 bytes 7 * header policy with 10000 characters diff --git a/testsuite/tests/apicast/policy/test_maintenance_mode_policy.py b/testsuite/tests/apicast/policy/test_maintenance_mode_policy.py index bff7c0b27..743e0b184 100644 --- a/testsuite/tests/apicast/policy/test_maintenance_mode_policy.py +++ b/testsuite/tests/apicast/policy/test_maintenance_mode_policy.py @@ -5,6 +5,7 @@ """ import pytest + from testsuite import rawobj diff --git a/testsuite/tests/apicast/policy/test_routing_url_rewriting_policy.py b/testsuite/tests/apicast/policy/test_routing_url_rewriting_policy.py index b1a53779f..0cef3b357 100644 --- a/testsuite/tests/apicast/policy/test_routing_url_rewriting_policy.py +++ b/testsuite/tests/apicast/policy/test_routing_url_rewriting_policy.py @@ -5,6 +5,7 @@ from urllib.parse import urlparse import pytest + from testsuite import rawobj from testsuite.echoed_request import EchoedRequest diff --git a/testsuite/tests/apicast/policy/test_upstream_connection.py b/testsuite/tests/apicast/policy/test_upstream_connection.py index bde842411..910ab1a04 100644 --- a/testsuite/tests/apicast/policy/test_upstream_connection.py +++ b/testsuite/tests/apicast/policy/test_upstream_connection.py @@ -1,13 +1,12 @@ "testing proper function of upstream test connection" -from packaging.version import Version # noqa # pylint: disable=unused-import - import pytest +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj from testsuite.utils import warn_and_skip -pytestmark = pytest.mark.skipif("TESTED_VERSION < Version('2.6')") +pytestmark = pytest.mark.skipif(TESTED_VERSION < Version("2.6"), reason="TESTED_VERSION < Version('2.6')") # https://github.com/3scale/apicast-cloud-hosted diff --git a/testsuite/tests/apicast/policy/test_upstream_url_rewriting_policy.py b/testsuite/tests/apicast/policy/test_upstream_url_rewriting_policy.py index f33c75817..5c35539a4 100644 --- a/testsuite/tests/apicast/policy/test_upstream_url_rewriting_policy.py +++ b/testsuite/tests/apicast/policy/test_upstream_url_rewriting_policy.py @@ -6,8 +6,7 @@ import pytest -from testsuite import rawobj -from testsuite import resilient +from testsuite import rawobj, resilient from testsuite.echoed_request import EchoedRequest diff --git a/testsuite/tests/apicast/policy/tls/conftest.py b/testsuite/tests/apicast/policy/tls/conftest.py index ea1213509..f8e1e7be2 100644 --- a/testsuite/tests/apicast/policy/tls/conftest.py +++ b/testsuite/tests/apicast/policy/tls/conftest.py @@ -1,7 +1,7 @@ """Module for setting up test that require TLS gateway and/or certificates""" -from weakget import weakget import pytest +from weakget import weakget from testsuite.certificates import Certificate, CertificateManager from testsuite.certificates.cfssl.cli import CFSSLProviderCLI diff --git a/testsuite/tests/apicast/policy/tls/test_http2_policy.py b/testsuite/tests/apicast/policy/tls/test_http2_policy.py index 6960f33bc..b2756d6c7 100644 --- a/testsuite/tests/apicast/policy/tls/test_http2_policy.py +++ b/testsuite/tests/apicast/policy/tls/test_http2_policy.py @@ -6,8 +6,8 @@ import testsuite from testsuite import rawobj # noqa # pylint: disable=unused-import -from testsuite.echoed_request import EchoedRequest from testsuite.capabilities import Capability +from testsuite.echoed_request import EchoedRequest from testsuite.httpx import HttpxClient # CFSSL instance is necessary diff --git a/testsuite/tests/apicast/policy/tls/test_tls_backend_routing.py b/testsuite/tests/apicast/policy/tls/test_tls_backend_routing.py index e1027f8bf..3699d1084 100644 --- a/testsuite/tests/apicast/policy/tls/test_tls_backend_routing.py +++ b/testsuite/tests/apicast/policy/tls/test_tls_backend_routing.py @@ -1,9 +1,9 @@ """ "Test for TLS Apicast with backend routing""" import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj from testsuite.capabilities import Capability from testsuite.echoed_request import EchoedRequest from testsuite.tests.apicast.policy.tls import embedded @@ -11,7 +11,7 @@ pytestmark = [ pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-8007"), - pytest.mark.skipif("TESTED_VERSION < Version('2.12')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.12"), reason="TESTED_VERSION < Version('2.12')"), ] diff --git a/testsuite/tests/apicast/policy/tls/test_tls_path_routing.py b/testsuite/tests/apicast/policy/tls/test_tls_path_routing.py index a544a2c6d..1f77611e4 100644 --- a/testsuite/tests/apicast/policy/tls/test_tls_path_routing.py +++ b/testsuite/tests/apicast/policy/tls/test_tls_path_routing.py @@ -4,9 +4,9 @@ import pytest import requests -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION, APICAST_OPERATOR_VERSION # noqa # pylint: disable=unused-import +from testsuite import APICAST_OPERATOR_VERSION, TESTED_VERSION, rawobj from testsuite.capabilities import Capability from testsuite.echoed_request import EchoedRequest from testsuite.tests.apicast.policy.tls import embedded @@ -16,8 +16,10 @@ pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-8000"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-8252"), - pytest.mark.skipif("TESTED_VERSION < Version('2.12')"), - pytest.mark.skipif("APICAST_OPERATOR_VERSION < Version('0.6.0')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.12"), reason="TESTED_VERSION < Version('2.12')"), + pytest.mark.skipif( + APICAST_OPERATOR_VERSION < Version("0.6.0"), reason="APICAST_OPERATOR_VERSION < Version('0.6.0')" + ), ] @@ -177,11 +179,11 @@ def test_tls_path_routing_with_logging(client, client2, staging_gateway): url2 = f'{client2._base_url}/bar/foo?user_key={client2.auth.credentials["user_key"]}' session = requests.Session() for _ in range(5): - response = session.get(url1, verify=False) + response = session.get(url1, verify=staging_gateway.server_authority.files["certificate"]) assert response.status_code == 200 echoed_request = EchoedRequest.create(response) assert echoed_request.json["path"] == "/service1/foo/bar" - response = session.get(url2, verify=False) + response = session.get(url2, verify=staging_gateway.server_authority.files["certificate"]) assert response.status_code == 200 echoed_request = EchoedRequest.create(response) assert echoed_request.json["path"] == "/service2/bar/foo" diff --git a/testsuite/tests/apicast/policy/tls/tls_upstream/conftest.py b/testsuite/tests/apicast/policy/tls/tls_upstream/conftest.py index 790d27dc9..8c29fdf93 100644 --- a/testsuite/tests/apicast/policy/tls/tls_upstream/conftest.py +++ b/testsuite/tests/apicast/policy/tls/tls_upstream/conftest.py @@ -4,9 +4,8 @@ from urllib.parse import urlparse -import pytest - import importlib_resources as resources +import pytest from testsuite.certificates import Certificate from testsuite.utils import blame diff --git a/testsuite/tests/apicast/policy/tls/tls_upstream/mtls_apicast_cert_validation/test_apicast_http_proxy_cert.py b/testsuite/tests/apicast/policy/tls/tls_upstream/mtls_apicast_cert_validation/test_apicast_http_proxy_cert.py index 467b40326..3305dd784 100644 --- a/testsuite/tests/apicast/policy/tls/tls_upstream/mtls_apicast_cert_validation/test_apicast_http_proxy_cert.py +++ b/testsuite/tests/apicast/policy/tls/tls_upstream/mtls_apicast_cert_validation/test_apicast_http_proxy_cert.py @@ -6,8 +6,8 @@ import pytest -from testsuite.certificates import Certificate from testsuite.capabilities import Capability +from testsuite.certificates import Certificate from testsuite.gateways import gateway from testsuite.gateways.apicast.template import TemplateApicast from testsuite.utils import blame diff --git a/testsuite/tests/apicast/policy/tls/tls_upstream/mtls_apicast_cert_validation/test_upstream_mtls_policy_standard_gateway.py b/testsuite/tests/apicast/policy/tls/tls_upstream/mtls_apicast_cert_validation/test_upstream_mtls_policy_standard_gateway.py index 2d8eb7cfe..e7407fd2c 100644 --- a/testsuite/tests/apicast/policy/tls/tls_upstream/mtls_apicast_cert_validation/test_upstream_mtls_policy_standard_gateway.py +++ b/testsuite/tests/apicast/policy/tls/tls_upstream/mtls_apicast_cert_validation/test_upstream_mtls_policy_standard_gateway.py @@ -10,7 +10,7 @@ import pytest -from testsuite import rawobj, gateways +from testsuite import gateways, rawobj from testsuite.capabilities import Capability from testsuite.certificates import Certificate from testsuite.tests.apicast.policy.tls import embedded diff --git a/testsuite/tests/apicast/policy/tls/tls_upstream/mtls_upstream_cert_validation/test_upstream_mtls_policy_upstream_cert_validation.py b/testsuite/tests/apicast/policy/tls/tls_upstream/mtls_upstream_cert_validation/test_upstream_mtls_policy_upstream_cert_validation.py index 2ad375fea..e386e55fe 100644 --- a/testsuite/tests/apicast/policy/tls/tls_upstream/mtls_upstream_cert_validation/test_upstream_mtls_policy_upstream_cert_validation.py +++ b/testsuite/tests/apicast/policy/tls/tls_upstream/mtls_upstream_cert_validation/test_upstream_mtls_policy_upstream_cert_validation.py @@ -11,18 +11,17 @@ from urllib.parse import urlparse import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import - +from testsuite import TESTED_VERSION, rawobj from testsuite.capabilities import Capability from testsuite.openshift.objects import Routes from testsuite.tests.apicast.policy.tls import embedded -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import from testsuite.utils import blame pytestmark = [ pytest.mark.required_capabilities(Capability.STANDARD_GATEWAY, Capability.CUSTOM_ENVIRONMENT), - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-7099"), ] diff --git a/testsuite/tests/apicast/policy/tls/tls_upstream/tls_passthrough_connection_reuse/conftest.py b/testsuite/tests/apicast/policy/tls/tls_upstream/tls_passthrough_connection_reuse/conftest.py index 6154d4b68..a2dbdf5c3 100644 --- a/testsuite/tests/apicast/policy/tls/tls_upstream/tls_passthrough_connection_reuse/conftest.py +++ b/testsuite/tests/apicast/policy/tls/tls_upstream/tls_passthrough_connection_reuse/conftest.py @@ -4,7 +4,7 @@ import pytest -from testsuite import rawobj, gateways +from testsuite import gateways, rawobj from testsuite.openshift.objects import Routes from testsuite.tests.apicast.policy.tls import embedded diff --git a/testsuite/tests/apicast/policy/tls/tls_upstream/tls_passthrough_connection_reuse/test_connection_reuse.py b/testsuite/tests/apicast/policy/tls/tls_upstream/tls_passthrough_connection_reuse/test_connection_reuse.py index 5f9dfb2e3..ca4f36b32 100644 --- a/testsuite/tests/apicast/policy/tls/tls_upstream/tls_passthrough_connection_reuse/test_connection_reuse.py +++ b/testsuite/tests/apicast/policy/tls/tls_upstream/tls_passthrough_connection_reuse/test_connection_reuse.py @@ -6,14 +6,14 @@ """ import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.echoed_request import EchoedRequest pytestmark = [ pytest.mark.nopersistence, - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6849"), ] diff --git a/testsuite/tests/apicast/policy/url_rewriting/test_url_rewriting_http_method.py b/testsuite/tests/apicast/policy/url_rewriting/test_url_rewriting_http_method.py index 96f88685e..1bfcf6bd3 100644 --- a/testsuite/tests/apicast/policy/url_rewriting/test_url_rewriting_http_method.py +++ b/testsuite/tests/apicast/policy/url_rewriting/test_url_rewriting_http_method.py @@ -3,13 +3,13 @@ http method of the request. """ -from packaging.version import Version # noqa # pylint: disable=unused-import import pytest +from packaging.version import Version + +from testsuite import TESTED_VERSION, rawobj from testsuite.echoed_request import EchoedRequest -from testsuite import rawobj -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import -pytestmark = [pytest.mark.skipif("TESTED_VERSION < Version('2.9')")] +pytestmark = [pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')")] @pytest.fixture(scope="module") diff --git a/testsuite/tests/apicast/policy/url_rewriting/test_url_rewriting_policy_query_liquid_set.py b/testsuite/tests/apicast/policy/url_rewriting/test_url_rewriting_policy_query_liquid_set.py index 8f4049ff6..8aa7d5b7e 100644 --- a/testsuite/tests/apicast/policy/url_rewriting/test_url_rewriting_policy_query_liquid_set.py +++ b/testsuite/tests/apicast/policy/url_rewriting/test_url_rewriting_policy_query_liquid_set.py @@ -4,7 +4,9 @@ from typing import Dict, List from urllib.parse import urlparse + import pytest + from testsuite import rawobj from testsuite.echoed_request import EchoedRequest diff --git a/testsuite/tests/apicast/policy/url_rewriting/test_url_rewriting_policy_with_apiap.py b/testsuite/tests/apicast/policy/url_rewriting/test_url_rewriting_policy_with_apiap.py index 8b29e4ae6..c7851ed3b 100644 --- a/testsuite/tests/apicast/policy/url_rewriting/test_url_rewriting_policy_with_apiap.py +++ b/testsuite/tests/apicast/policy/url_rewriting/test_url_rewriting_policy_with_apiap.py @@ -3,12 +3,12 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.8')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.8"), reason="TESTED_VERSION < Version('2.8')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-4301"), ] diff --git a/testsuite/tests/apicast/policy/url_rewriting/test_url_rewriting_query_invalid_liquid.py b/testsuite/tests/apicast/policy/url_rewriting/test_url_rewriting_query_invalid_liquid.py index b11ee77f3..160050f4c 100644 --- a/testsuite/tests/apicast/policy/url_rewriting/test_url_rewriting_query_invalid_liquid.py +++ b/testsuite/tests/apicast/policy/url_rewriting/test_url_rewriting_query_invalid_liquid.py @@ -3,6 +3,7 @@ """ import pytest + from testsuite import rawobj from testsuite.echoed_request import EchoedRequest diff --git a/testsuite/tests/apicast/policy/url_rewriting_captures/test_http_methods.py b/testsuite/tests/apicast/policy/url_rewriting_captures/test_http_methods.py index 3e94c9297..3017521bb 100644 --- a/testsuite/tests/apicast/policy/url_rewriting_captures/test_http_methods.py +++ b/testsuite/tests/apicast/policy/url_rewriting_captures/test_http_methods.py @@ -4,13 +4,13 @@ """ import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj from testsuite.echoed_request import EchoedRequest pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.10')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.10"), reason="TESTED_VERSION < Version('2.10')"), pytest.mark.issue("https://issues.jboss.org/browse/THREESCALE-6270"), ] diff --git a/testsuite/tests/apicast/policy/websocket/test_websocket_policy_app_id.py b/testsuite/tests/apicast/policy/websocket/test_websocket_policy_app_id.py index 3e98150a3..446dfae94 100644 --- a/testsuite/tests/apicast/policy/websocket/test_websocket_policy_app_id.py +++ b/testsuite/tests/apicast/policy/websocket/test_websocket_policy_app_id.py @@ -9,16 +9,21 @@ https://docs.openshift.com/container-platform/4.9/networking/ingress-operator.html#nw-http2-haproxy_configuring-ingress """ -from packaging.version import Version # noqa # pylint: disable=unused-import - import pytest +from packaging.version import Version from threescale_api.resources import Service -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import -from testsuite.tests.apicast.policy.websocket.conftest import retry_sucessful, retry_failing +from testsuite import TESTED_VERSION +from testsuite.tests.apicast.policy.websocket.conftest import ( + retry_failing, + retry_sucessful, +) # websockets may fail for reason described above -pytestmark = [pytest.mark.sandbag, pytest.mark.skipif("TESTED_VERSION < Version('2.8')")] +pytestmark = [ + pytest.mark.sandbag, + pytest.mark.skipif(TESTED_VERSION < Version("2.8"), reason="TESTED_VERSION < Version('2.8')"), +] @pytest.fixture diff --git a/testsuite/tests/apicast/policy/websocket/test_websocket_policy_user_key.py b/testsuite/tests/apicast/policy/websocket/test_websocket_policy_user_key.py index 0f7609656..b4d95ae56 100644 --- a/testsuite/tests/apicast/policy/websocket/test_websocket_policy_user_key.py +++ b/testsuite/tests/apicast/policy/websocket/test_websocket_policy_user_key.py @@ -9,15 +9,20 @@ https://docs.openshift.com/container-platform/4.9/networking/ingress-operator.html#nw-http2-haproxy_configuring-ingress """ -from packaging.version import Version # noqa # pylint: disable=unused-import - import pytest +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import -from testsuite.tests.apicast.policy.websocket.conftest import retry_sucessful, retry_failing +from testsuite import TESTED_VERSION +from testsuite.tests.apicast.policy.websocket.conftest import ( + retry_failing, + retry_sucessful, +) # websockets may fail for reason described above -pytestmark = [pytest.mark.sandbag, pytest.mark.skipif("TESTED_VERSION < Version('2.8')")] +pytestmark = [ + pytest.mark.sandbag, + pytest.mark.skipif(TESTED_VERSION < Version("2.8"), reason="TESTED_VERSION < Version('2.8')"), +] @pytest.fixture diff --git a/testsuite/tests/apicast/policy/websocket/test_websocket_policy_wss_backend.py b/testsuite/tests/apicast/policy/websocket/test_websocket_policy_wss_backend.py index 9b07b065e..f907c2a7f 100644 --- a/testsuite/tests/apicast/policy/websocket/test_websocket_policy_wss_backend.py +++ b/testsuite/tests/apicast/policy/websocket/test_websocket_policy_wss_backend.py @@ -9,15 +9,20 @@ https://docs.openshift.com/container-platform/4.9/networking/ingress-operator.html#nw-http2-haproxy_configuring-ingress """ -from packaging.version import Version # noqa # pylint: disable=unused-import - import pytest +from packaging.version import Version -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import -from testsuite.tests.apicast.policy.websocket.conftest import retry_sucessful, retry_failing +from testsuite import TESTED_VERSION +from testsuite.tests.apicast.policy.websocket.conftest import ( + retry_failing, + retry_sucessful, +) # websockets may fail for reason described above -pytestmark = [pytest.mark.sandbag, pytest.mark.skipif("TESTED_VERSION < Version('2.8')")] +pytestmark = [ + pytest.mark.sandbag, + pytest.mark.skipif(TESTED_VERSION < Version("2.8"), reason="TESTED_VERSION < Version('2.8')"), +] @pytest.fixture(scope="module") diff --git a/testsuite/tests/apicast/test_apicast_logs.py b/testsuite/tests/apicast/test_apicast_logs.py index 235fdbf2e..ac16d09b8 100644 --- a/testsuite/tests/apicast/test_apicast_logs.py +++ b/testsuite/tests/apicast/test_apicast_logs.py @@ -3,11 +3,11 @@ import re import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION -pytestmark = [pytest.mark.skipif("TESTED_VERSION < Version('2.14-dev')")] +pytestmark = [pytest.mark.skipif(TESTED_VERSION < Version("2.14-dev"), reason="TESTED_VERSION < Version('2.14-dev')")] @pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-7942") diff --git a/testsuite/tests/apicast/test_disabled_method.py b/testsuite/tests/apicast/test_disabled_method.py index 140a0f34b..15e9c630d 100644 --- a/testsuite/tests/apicast/test_disabled_method.py +++ b/testsuite/tests/apicast/test_disabled_method.py @@ -3,6 +3,7 @@ """ import pytest + from testsuite import rawobj pytestmark = pytest.mark.issue("https://issues.jboss.org/browse/THREESCALE-3330") diff --git a/testsuite/tests/apicast/test_hit_limit.py b/testsuite/tests/apicast/test_hit_limit.py index 945f8d9f9..33b82ef9c 100644 --- a/testsuite/tests/apicast/test_hit_limit.py +++ b/testsuite/tests/apicast/test_hit_limit.py @@ -13,11 +13,12 @@ be accepted. """ -from datetime import datetime, timezone import time +from datetime import datetime, timezone import backoff import pytest + from testsuite import rawobj from testsuite.utils import blame, wait_interval, wait_until_next_minute diff --git a/testsuite/tests/apicast/test_strip_standard_https_ports.py b/testsuite/tests/apicast/test_strip_standard_https_ports.py index 1d842b9ae..9c33739ce 100644 --- a/testsuite/tests/apicast/test_strip_standard_https_ports.py +++ b/testsuite/tests/apicast/test_strip_standard_https_ports.py @@ -3,15 +3,14 @@ """ import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import - -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.echoed_request import EchoedRequest from testsuite.utils import blame, warn_and_skip pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-2235"), ] diff --git a/testsuite/tests/apicast/test_uri_too_large.py b/testsuite/tests/apicast/test_uri_too_large.py index c21d738b9..642fb3583 100644 --- a/testsuite/tests/apicast/test_uri_too_large.py +++ b/testsuite/tests/apicast/test_uri_too_large.py @@ -1,9 +1,9 @@ """Test for apicast logs with 414 Request-URI Too Large response""" import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.capabilities import Capability WARN_MESSAGES = [ @@ -16,7 +16,7 @@ pytestmark = [ pytest.mark.required_capabilities(Capability.LOGS), - pytest.mark.skipif("TESTED_VERSION < Version('2.13')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.13"), reason="TESTED_VERSION < Version('2.13')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-7906"), pytest.mark.issue("https://issues.redhat.com/browse/MGDAPI-5655"), ] diff --git a/testsuite/tests/apicast/webhooks/test_webhook_user.py b/testsuite/tests/apicast/webhooks/test_webhook_user.py index 7b26eabde..d3a868cc1 100644 --- a/testsuite/tests/apicast/webhooks/test_webhook_user.py +++ b/testsuite/tests/apicast/webhooks/test_webhook_user.py @@ -4,16 +4,15 @@ import xml.etree.ElementTree as Et -from packaging.version import Version # noqa # pylint: disable=unused-import - import pytest +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.utils import blame # webhook tests seem disruptive to requestbin as they reset it with no mercy pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.8.3')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.8.3"), reason="TESTED_VERSION < Version('2.8.3')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-5207"), pytest.mark.disruptive, ] diff --git a/testsuite/tests/apicast/webhooks/test_webhooks_account.py b/testsuite/tests/apicast/webhooks/test_webhooks_account.py index 0b99ff9ba..33b333df1 100644 --- a/testsuite/tests/apicast/webhooks/test_webhooks_account.py +++ b/testsuite/tests/apicast/webhooks/test_webhooks_account.py @@ -4,16 +4,15 @@ import xml.etree.ElementTree as Et -from packaging.version import Version # noqa # pylint: disable=unused-import - import pytest +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.utils import blame # webhook tests seem disruptive to requestbin as they reset it with no mercy pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.8.3')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.8.3"), reason="TESTED_VERSION < Version('2.8.3')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-5207"), pytest.mark.disruptive, ] diff --git a/testsuite/tests/apicast/webhooks/test_webhooks_applications.py b/testsuite/tests/apicast/webhooks/test_webhooks_applications.py index 6daa2d726..a7eaebbd7 100644 --- a/testsuite/tests/apicast/webhooks/test_webhooks_applications.py +++ b/testsuite/tests/apicast/webhooks/test_webhooks_applications.py @@ -4,17 +4,15 @@ import xml.etree.ElementTree as Et -from packaging.version import Version # noqa # pylint: disable=unused-import - import pytest +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import -from testsuite import rawobj +from testsuite import TESTED_VERSION, rawobj from testsuite.utils import blame # webhook tests seem disruptive to requestbin as they reset it with no mercy pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.8.3')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.8.3"), reason="TESTED_VERSION < Version('2.8.3')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-5207"), pytest.mark.disruptive, ] diff --git a/testsuite/tests/apicast/webhooks/test_webhooks_keys.py b/testsuite/tests/apicast/webhooks/test_webhooks_keys.py index 1cbf05b4f..4024f86e8 100644 --- a/testsuite/tests/apicast/webhooks/test_webhooks_keys.py +++ b/testsuite/tests/apicast/webhooks/test_webhooks_keys.py @@ -2,16 +2,15 @@ Based on spec/ui_specs/webhooks/webhooks_keys_spec.rb (ruby test is via UI) """ -from packaging.version import Version # noqa # pylint: disable=unused-import - import pytest +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.utils import blame # webhook tests seem disruptive to requestbin as they reset it with no mercy pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.8.3')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.8.3"), reason="TESTED_VERSION < Version('2.8.3')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-5207"), pytest.mark.disruptive, ] diff --git a/testsuite/tests/apicast_operator/test_annotations.py b/testsuite/tests/apicast_operator/test_annotations.py index b0f92fcd7..355872452 100644 --- a/testsuite/tests/apicast_operator/test_annotations.py +++ b/testsuite/tests/apicast_operator/test_annotations.py @@ -2,12 +2,12 @@ Check if annotations of apicast-operator pod are present """ -from typing import Tuple, List, Union +from typing import List, Tuple, Union import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import APICAST_OPERATOR_VERSION # noqa # pylint: disable=unused-import +from testsuite import APICAST_OPERATOR_VERSION from testsuite.capabilities import Capability pytestmark = [ @@ -37,7 +37,9 @@ ] -@pytest.mark.skipif("APICAST_OPERATOR_VERSION > Version('0.6.0')") # since threescale 2.12 +@pytest.mark.skipif( + APICAST_OPERATOR_VERSION > Version("0.6.0"), reason="APICAST_OPERATOR_VERSION > Version('0.6.0')" +) # since threescale 2.12 @pytest.mark.parametrize("annotation,expected_value", ANNOTATIONS_PRE_2_12) def test_labels_operator_old(annotation, expected_value, apicast_operator): """Test labels of operator pod.""" @@ -47,7 +49,7 @@ def test_labels_operator_old(annotation, expected_value, apicast_operator): assert value == expected_value -@pytest.mark.skipif("APICAST_OPERATOR_VERSION <= Version('0.6.0')") +@pytest.mark.skipif(APICAST_OPERATOR_VERSION <= Version("0.6.0"), reason="APICAST_OPERATOR_VERSION <= Version('0.6.0')") @pytest.mark.parametrize("annotation,expected_value", ANNOTATIONS_POST_2_12) def test_labels_operator_new(annotation, expected_value, apicast_operator): """Test labels of operator pod.""" diff --git a/testsuite/tests/apicast_operator/test_labels.py b/testsuite/tests/apicast_operator/test_labels.py index aeada8ec9..1497e2e20 100644 --- a/testsuite/tests/apicast_operator/test_labels.py +++ b/testsuite/tests/apicast_operator/test_labels.py @@ -2,12 +2,12 @@ Check if labels of apicast operator pod are present """ -from typing import Tuple, List, Union +from typing import List, Tuple, Union import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import APICAST_OPERATOR_VERSION # noqa # pylint: disable=unused-import +from testsuite import APICAST_OPERATOR_VERSION from testsuite.capabilities import Capability pytestmark = [ @@ -35,7 +35,9 @@ ] -@pytest.mark.skipif("APICAST_OPERATOR_VERSION > Version('0.6.0')") # since threescale 2.12 +@pytest.mark.skipif( + APICAST_OPERATOR_VERSION > Version("0.6.0"), reason="APICAST_OPERATOR_VERSION > Version('0.6.0')" +) # since threescale 2.12 @pytest.mark.parametrize("label,expected_value", LABELS_PRE_2_12) def test_labels_operator_old(label, expected_value, apicast_operator): """Test labels of apicast operator pod.""" @@ -45,7 +47,7 @@ def test_labels_operator_old(label, expected_value, apicast_operator): assert value == expected_value -@pytest.mark.skipif("APICAST_OPERATOR_VERSION <= Version('0.6.0')") +@pytest.mark.skipif(APICAST_OPERATOR_VERSION <= Version("0.6.0"), reason="APICAST_OPERATOR_VERSION <= Version('0.6.0')") @pytest.mark.parametrize("label,expected_value", LABELS_POST_2_12) def test_labels_operator_new(label, expected_value, apicast_operator, logger): """Test labels of apicast operator pod.""" diff --git a/testsuite/tests/conftest.py b/testsuite/tests/conftest.py index 0a76c63e6..fe30a2f8d 100644 --- a/testsuite/tests/conftest.py +++ b/testsuite/tests/conftest.py @@ -23,18 +23,18 @@ # to actually initialize all the providers # pylint: disable=unused-import import testsuite.capabilities.providers # noqa -from testsuite.tools import Tools -from testsuite import TESTED_VERSION, rawobj, HTTP2, gateways, configuration, resilient +from testsuite import HTTP2, TESTED_VERSION, configuration, gateways, rawobj, resilient from testsuite.capabilities import Capability, CapabilityRegistry from testsuite.config import settings from testsuite.httpx import HttpxHook +from testsuite.mailhog import MailhogClient from testsuite.mockserver import Mockserver from testsuite.openshift.client import OpenShiftClient from testsuite.prometheus import PrometheusClient -from testsuite.rhsso import RHSSOServiceConfiguration, RHSSO +from testsuite.rhsso import RHSSO, RHSSOServiceConfiguration from testsuite.toolbox import toolbox +from testsuite.tools import Tools from testsuite.utils import blame, blame_desc, warn_and_skip -from testsuite.mailhog import MailhogClient if weakget(settings)["reporting"]["print_app_logs"] % True: pytest_plugins = ("testsuite.gateway_logs",) diff --git a/testsuite/tests/fuzz/test_app_id_special_chars.py b/testsuite/tests/fuzz/test_app_id_special_chars.py index 1b64816fc..ae559f033 100644 --- a/testsuite/tests/fuzz/test_app_id_special_chars.py +++ b/testsuite/tests/fuzz/test_app_id_special_chars.py @@ -4,8 +4,8 @@ from threescale_api.resources import Service from testsuite import rawobj -from testsuite.echoed_request import EchoedRequest from testsuite.capabilities import Capability +from testsuite.echoed_request import EchoedRequest from testsuite.utils import blame pytestmark = [pytest.mark.required_capabilities(Capability.PRODUCTION_GATEWAY)] diff --git a/testsuite/tests/grafana/conftest.py b/testsuite/tests/grafana/conftest.py index a711ae954..fa8fdff26 100644 --- a/testsuite/tests/grafana/conftest.py +++ b/testsuite/tests/grafana/conftest.py @@ -1,8 +1,8 @@ """Check for openshift configuration""" +import pytest from openshift_client import Missing from weakget import weakget -import pytest from testsuite.utils import warn_and_skip diff --git a/testsuite/tests/grafana/test_dashboards.py b/testsuite/tests/grafana/test_dashboards.py index 3e7d341ff..59176cb4b 100644 --- a/testsuite/tests/grafana/test_dashboards.py +++ b/testsuite/tests/grafana/test_dashboards.py @@ -1,13 +1,13 @@ """Tests for Grafana Dashboards definitions""" import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.capabilities import Capability pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.9')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')"), pytest.mark.required_capabilities(Capability.OCP4), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-7961"), ] diff --git a/testsuite/tests/images/test_images_check.py b/testsuite/tests/images/test_images_check.py index 7b97e0828..7b8739288 100644 --- a/testsuite/tests/images/test_images_check.py +++ b/testsuite/tests/images/test_images_check.py @@ -1,15 +1,13 @@ """Image checkt tests""" import pytest - -from packaging.version import Version # noqa # pylint: disable=unused-import - from openshift_client import OpenShiftPythonException +from packaging.version import Version +from testsuite import TESTED_VERSION from testsuite.gateways import gateway from testsuite.gateways.apicast.operator import OperatorApicast from testsuite.utils import blame -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import pytestmark = pytest.mark.nopersistence @@ -43,7 +41,7 @@ def threescale(): @pytest.mark.parametrize(("image", "image_stream"), IS_PARAMETERS) # INFO: image streams are no longer used (starting with 2.15-dev) -@pytest.mark.skipif("TESTED_VERSION > Version('2.14')") +@pytest.mark.skipif(TESTED_VERSION > Version("2.14"), reason="TESTED_VERSION > Version('2.14')") def test_imagesource_image(images, openshift, image, image_stream): """ Test: diff --git a/testsuite/tests/operator/test_annotations.py b/testsuite/tests/operator/test_annotations.py index 159b18cf2..50833b066 100644 --- a/testsuite/tests/operator/test_annotations.py +++ b/testsuite/tests/operator/test_annotations.py @@ -2,12 +2,12 @@ Check if annotations of operator pod are present """ -from typing import Tuple, List, Union +from typing import List, Tuple, Union import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.capabilities import Capability pytestmark = [ @@ -37,7 +37,7 @@ ] -@pytest.mark.skipif("TESTED_VERSION >= Version('2.12')") +@pytest.mark.skipif(TESTED_VERSION >= Version("2.12"), reason="TESTED_VERSION >= Version('2.12')") @pytest.mark.parametrize("annotation,expected_value", ANNOTATIONS_PRE_2_12) def test_labels_operator_old(annotation, expected_value, operator): """Test labels of operator pod.""" @@ -47,7 +47,7 @@ def test_labels_operator_old(annotation, expected_value, operator): assert value == expected_value -@pytest.mark.skipif("TESTED_VERSION < Version('2.12')") +@pytest.mark.skipif(TESTED_VERSION < Version("2.12"), reason="TESTED_VERSION < Version('2.12')") @pytest.mark.parametrize("annotation,expected_value", ANNOTATIONS_POST_2_12) def test_labels_operator_new(annotation, expected_value, operator): """Test labels of operator pod.""" diff --git a/testsuite/tests/operator/test_labels.py b/testsuite/tests/operator/test_labels.py index 6c10a1a0a..a5fb42d9d 100644 --- a/testsuite/tests/operator/test_labels.py +++ b/testsuite/tests/operator/test_labels.py @@ -2,12 +2,12 @@ Check if labels of operator pod are present """ -from typing import Tuple, List, Union +from typing import List, Tuple, Union import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.capabilities import Capability pytestmark = [ @@ -38,7 +38,7 @@ ] -@pytest.mark.skipif("TESTED_VERSION >= Version('2.12')") +@pytest.mark.skipif(TESTED_VERSION >= Version("2.12"), reason="TESTED_VERSION >= Version('2.12')") @pytest.mark.parametrize("label,expected_value", LABELS_PRE_2_12) def test_labels_operator_old(label, expected_value, operator): """Test labels of operator pod.""" @@ -48,7 +48,7 @@ def test_labels_operator_old(label, expected_value, operator): assert value == expected_value -@pytest.mark.skipif("TESTED_VERSION < Version('2.12')") +@pytest.mark.skipif(TESTED_VERSION < Version("2.12"), reason="TESTED_VERSION < Version('2.12')") @pytest.mark.parametrize("label,expected_value", LABELS_POST_2_12) def test_labels_operator_new(label, expected_value, operator): """Test labels of operator pod.""" diff --git a/testsuite/tests/operator/test_operator_resources.py b/testsuite/tests/operator/test_operator_resources.py index 62c68684b..2ccfcb257 100644 --- a/testsuite/tests/operator/test_operator_resources.py +++ b/testsuite/tests/operator/test_operator_resources.py @@ -3,15 +3,16 @@ """ import re -import pytest +import pytest from packaging.version import Version + from testsuite import TESTED_VERSION from testsuite.capabilities import Capability pytestmark = [ pytest.mark.sandbag, # requires operator in same namespace - pytest.mark.skipif("TESTED_VERSION < Version('2.10')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.10"), reason="TESTED_VERSION < Version('2.10')"), pytest.mark.required_capabilities(Capability.OCP4), pytest.mark.nopersistence, ] diff --git a/testsuite/tests/performance/conftest.py b/testsuite/tests/performance/conftest.py index f25ead7aa..254fb0508 100644 --- a/testsuite/tests/performance/conftest.py +++ b/testsuite/tests/performance/conftest.py @@ -6,16 +6,14 @@ import os from concurrent.futures.thread import ThreadPoolExecutor from pathlib import Path -from weakget import weakget import pytest - from hyperfoil import HyperfoilClient - -from testsuite.perf_utils import HyperfoilUtils +from weakget import weakget from testsuite import rawobj -from testsuite.utils import randomize, blame +from testsuite.perf_utils import HyperfoilUtils +from testsuite.utils import blame, randomize @pytest.fixture(scope="session") diff --git a/testsuite/tests/prometheus/apicast/selfmanaged/conftest.py b/testsuite/tests/prometheus/apicast/selfmanaged/conftest.py index 51afbb376..566f40212 100644 --- a/testsuite/tests/prometheus/apicast/selfmanaged/conftest.py +++ b/testsuite/tests/prometheus/apicast/selfmanaged/conftest.py @@ -1,7 +1,7 @@ """Provide custom gateway for tests changing apicast parameters.""" -from weakget import weakget import pytest +from weakget import weakget from testsuite.gateways import gateway from testsuite.gateways.apicast.operator import OperatorApicast diff --git a/testsuite/tests/prometheus/apicast/selfmanaged/test_batching_caching_policy.py b/testsuite/tests/prometheus/apicast/selfmanaged/test_batching_caching_policy.py index 849c077c3..c682b4845 100644 --- a/testsuite/tests/prometheus/apicast/selfmanaged/test_batching_caching_policy.py +++ b/testsuite/tests/prometheus/apicast/selfmanaged/test_batching_caching_policy.py @@ -3,16 +3,19 @@ """ from datetime import datetime, timedelta, timezone + import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import APICAST_OPERATOR_VERSION, rawobj # noqa # pylint: disable=unused-import +from testsuite import APICAST_OPERATOR_VERSION, rawobj from testsuite.capabilities import Capability from testsuite.prometheus import get_metrics_keys pytestmark = [ pytest.mark.nopersistence, - pytest.mark.skipif("APICAST_OPERATOR_VERSION < Version('0.5.2')"), + pytest.mark.skipif( + APICAST_OPERATOR_VERSION < Version("0.5.2"), reason="APICAST_OPERATOR_VERSION < Version('0.5.2')" + ), pytest.mark.required_capabilities(Capability.OCP4, Capability.APICAST), ] diff --git a/testsuite/tests/prometheus/apicast/test_content_caching_policy.py b/testsuite/tests/prometheus/apicast/test_content_caching_policy.py index 19f966c74..fd7a7a068 100644 --- a/testsuite/tests/prometheus/apicast/test_content_caching_policy.py +++ b/testsuite/tests/prometheus/apicast/test_content_caching_policy.py @@ -4,13 +4,13 @@ import backoff import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj from testsuite.prometheus import get_metrics_keys pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.9')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-5439"), ] diff --git a/testsuite/tests/prometheus/apicast/test_metric_worker_starts.py b/testsuite/tests/prometheus/apicast/test_metric_worker_starts.py index 266154254..a584d69df 100644 --- a/testsuite/tests/prometheus/apicast/test_metric_worker_starts.py +++ b/testsuite/tests/prometheus/apicast/test_metric_worker_starts.py @@ -4,12 +4,12 @@ """ import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.9.1')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9.1"), reason="TESTED_VERSION < Version('2.9.1')"), pytest.mark.disruptive, ] diff --git a/testsuite/tests/prometheus/apicast/test_metrics.py b/testsuite/tests/prometheus/apicast/test_metrics.py index 12ed61483..314ae0679 100644 --- a/testsuite/tests/prometheus/apicast/test_metrics.py +++ b/testsuite/tests/prometheus/apicast/test_metrics.py @@ -5,10 +5,8 @@ import backoff import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import from testsuite.capabilities import Capability -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import from testsuite.prometheus import get_metrics_keys pytestmark = [ @@ -40,9 +38,36 @@ # pylint: disable=unused-argument -@pytest.fixture(scope="module", params=["apicast-staging", "apicast-production"]) -def metrics(request, prometheus): +@pytest.fixture( + scope="module", params=["apicast-staging", pytest.param("apicast-production", marks=pytest.mark.disruptive)] +) +def metrics(request, prometheus, application, api_client): """Return all metrics from target defined of staging and also production apicast.""" + # Check if any required metrics don't exist + existing_metrics = get_metrics_keys(prometheus.get_metrics(labels={"container": request.param})) + + required_standard_metrics = ["threescale_backend_calls", "upstream_status", "apicast_status"] + required_histogram_metrics = ["total_response_time_seconds", "upstream_response_time_seconds"] + + standard_missing = any(metric not in existing_metrics for metric in required_standard_metrics) + + histogram_missing = any( + f"{metric}_{suffix}" not in existing_metrics + for metric in required_histogram_metrics + for suffix in ["_bucket", "_sum", "_count"] + ) + + # If some metrics do not exist, trigger with explicit HTTP request + if standard_missing or histogram_missing: + if request.param == "apicast-production": + prod_client = request.getfixturevalue("prod_client") + client = prod_client() + else: + client = api_client() + + client.get("/get") + prometheus.wait_on_next_scrape(request.param) + metrics = get_metrics_keys(prometheus.get_metrics(labels={"container": request.param})) return metrics @@ -88,9 +113,10 @@ def test_apicast_status_metrics(request, client, container, prometheus): Apicast logs http status codes on prometheus as a counter. """ - - client = request.getfixturevalue(client) - client = client() + if client == "prod_client": + client = request.getfixturevalue(client)(promote=False) + else: + client = request.getfixturevalue(client)() for status in STATUSES: assert client.get(f"/status/{status}").status_code == status diff --git a/testsuite/tests/prometheus/apicast_operator/conftest.py b/testsuite/tests/prometheus/apicast_operator/conftest.py index 3d3fef6a2..4082a8429 100644 --- a/testsuite/tests/prometheus/apicast_operator/conftest.py +++ b/testsuite/tests/prometheus/apicast_operator/conftest.py @@ -1,7 +1,7 @@ """Provide custom gateway for tests checking for Apicast Operator metrics.""" -from weakget import weakget import pytest +from weakget import weakget from testsuite.gateways import gateway from testsuite.gateways.apicast.operator import OperatorApicast diff --git a/testsuite/tests/prometheus/apicast_operator/test_metrics.py b/testsuite/tests/prometheus/apicast_operator/test_metrics.py index d02962e10..a48b73854 100644 --- a/testsuite/tests/prometheus/apicast_operator/test_metrics.py +++ b/testsuite/tests/prometheus/apicast_operator/test_metrics.py @@ -4,8 +4,6 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import @pytest.mark.xfail # xfail because Apicast does not have default ServiceMonitor created diff --git a/testsuite/tests/prometheus/backend_listener/test_backend_listener_api.py b/testsuite/tests/prometheus/backend_listener/test_backend_listener_api.py index becbba69d..3270c5594 100644 --- a/testsuite/tests/prometheus/backend_listener/test_backend_listener_api.py +++ b/testsuite/tests/prometheus/backend_listener/test_backend_listener_api.py @@ -5,15 +5,15 @@ status code, is expected in prometheus. """ -from typing import Tuple, Dict +from typing import Dict, Tuple import pytest import requests -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version +from testsuite import TESTED_VERSION, rawobj from testsuite.rhsso.rhsso import OIDCClientAuthHook from testsuite.utils import blame, randomize -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import NUM_OF_REQUESTS = 10 @@ -21,7 +21,7 @@ # can not be run in parallel pytest.mark.disruptive, pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-4641"), - pytest.mark.skipif("TESTED_VERSION < Version('2.10')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.10"), reason="TESTED_VERSION < Version('2.10')"), ] diff --git a/testsuite/tests/prometheus/backend_listener/test_backend_listener_internal_api.py b/testsuite/tests/prometheus/backend_listener/test_backend_listener_internal_api.py index 87af24407..527999827 100644 --- a/testsuite/tests/prometheus/backend_listener/test_backend_listener_internal_api.py +++ b/testsuite/tests/prometheus/backend_listener/test_backend_listener_internal_api.py @@ -5,15 +5,15 @@ """ import base64 -from datetime import timedelta, datetime, timezone +from datetime import datetime, timedelta, timezone from typing import Dict, Tuple import pytest import requests -from packaging.version import Version # noqa # pylint: disable=unused-import - +from packaging.version import Version from threescale_api.resources import Service -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import + +from testsuite import TESTED_VERSION NUM_OF_REQUESTS = 10 @@ -21,7 +21,7 @@ # can not be run in parallel pytest.mark.disruptive, pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6453"), - pytest.mark.skipif("TESTED_VERSION < Version('2.10')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.10"), reason="TESTED_VERSION < Version('2.10')"), ] diff --git a/testsuite/tests/prometheus/backend_listener/test_backend_worker_report_jobs.py b/testsuite/tests/prometheus/backend_listener/test_backend_worker_report_jobs.py index b650c79ba..115d017f3 100644 --- a/testsuite/tests/prometheus/backend_listener/test_backend_worker_report_jobs.py +++ b/testsuite/tests/prometheus/backend_listener/test_backend_worker_report_jobs.py @@ -5,9 +5,9 @@ import pytest import requests -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION NUM_OF_REQUESTS = 10 @@ -15,7 +15,7 @@ # can not be run in parallel pytest.mark.disruptive, pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-3176"), - pytest.mark.skipif("TESTED_VERSION < Version('2.10')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.10"), reason="TESTED_VERSION < Version('2.10')"), ] diff --git a/testsuite/tests/prometheus/operator/conftest.py b/testsuite/tests/prometheus/operator/conftest.py index 43420f12e..557058b91 100644 --- a/testsuite/tests/prometheus/operator/conftest.py +++ b/testsuite/tests/prometheus/operator/conftest.py @@ -1,7 +1,7 @@ """Verify we have prerequisites for Operator metrics tests.""" -from weakget import weakget import pytest +from weakget import weakget from testsuite.utils import warn_and_skip diff --git a/testsuite/tests/prometheus/operator/test_metrics.py b/testsuite/tests/prometheus/operator/test_metrics.py index 7a551e558..7b61377ae 100644 --- a/testsuite/tests/prometheus/operator/test_metrics.py +++ b/testsuite/tests/prometheus/operator/test_metrics.py @@ -5,6 +5,7 @@ import pytest from packaging.version import Version + from testsuite import TESTED_VERSION OPERATOR_SERVICE = ["threescale-operator-controller-manager-metrics-service"] diff --git a/testsuite/tests/prometheus/system/test_internal_calls.py b/testsuite/tests/prometheus/system/test_internal_calls.py index d07bdc877..36cf2896a 100644 --- a/testsuite/tests/prometheus/system/test_internal_calls.py +++ b/testsuite/tests/prometheus/system/test_internal_calls.py @@ -6,15 +6,15 @@ import pytest import requests +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION, rawobj # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.prometheus import get_metrics_keys pytestmark = [ pytest.mark.disruptive, pytest.mark.flaky, - pytest.mark.skipif("TESTED_VERSION < Version('2.10')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.10"), reason="TESTED_VERSION < Version('2.10')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6446"), ] diff --git a/testsuite/tests/prometheus/system/test_metrics.py b/testsuite/tests/prometheus/system/test_metrics.py index ab5617ccb..e71eedc0e 100644 --- a/testsuite/tests/prometheus/system/test_metrics.py +++ b/testsuite/tests/prometheus/system/test_metrics.py @@ -3,9 +3,9 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.prometheus import get_metrics_keys METRICS_MASTER = [ @@ -41,7 +41,7 @@ pytest.mark.sandbag, # requires openshfit pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-4743"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-9934"), - pytest.mark.skipif("TESTED_VERSION < Version('2.10')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.10"), reason="TESTED_VERSION < Version('2.10')"), ] diff --git a/testsuite/tests/prometheus/zync/test_annotations.py b/testsuite/tests/prometheus/zync/test_annotations.py index 5d4456dd8..b7f401197 100644 --- a/testsuite/tests/prometheus/zync/test_annotations.py +++ b/testsuite/tests/prometheus/zync/test_annotations.py @@ -3,16 +3,16 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import from openshift_client import OpenShiftPythonException +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION pytestmark = [ pytest.mark.sandbag, # requires openshift pytest.mark.nopersistence, # fixture saves pod name, which changes with pod redeployment pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6509"), - pytest.mark.skipif("TESTED_VERSION < Version('2.10')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.10"), reason="TESTED_VERSION < Version('2.10')"), ] ANNOTATIONS = ["prometheus.io/port", "prometheus.io/scrape"] diff --git a/testsuite/tests/prometheus/zync/test_metrics.py b/testsuite/tests/prometheus/zync/test_metrics.py index fbb02d243..8369971fc 100644 --- a/testsuite/tests/prometheus/zync/test_metrics.py +++ b/testsuite/tests/prometheus/zync/test_metrics.py @@ -3,15 +3,15 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.prometheus import get_metrics_keys pytestmark = [ pytest.mark.sandbag, # requires openshift pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-4642"), - pytest.mark.skipif("TESTED_VERSION < Version('2.10')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.10"), reason="TESTED_VERSION < Version('2.10')"), ] METRICS_QUE = [ diff --git a/testsuite/tests/service_mesh/auth/rhsso/test_rhsso_wrong_realm.py b/testsuite/tests/service_mesh/auth/rhsso/test_rhsso_wrong_realm.py index 8572507e5..533d21b6c 100644 --- a/testsuite/tests/service_mesh/auth/rhsso/test_rhsso_wrong_realm.py +++ b/testsuite/tests/service_mesh/auth/rhsso/test_rhsso_wrong_realm.py @@ -3,9 +3,9 @@ import pytest +from testsuite.capabilities import Capability from testsuite.rhsso import Token from testsuite.utils import blame -from testsuite.capabilities import Capability pytestmark = pytest.mark.required_capabilities(Capability.SERVICE_MESH) diff --git a/testsuite/tests/service_mesh/auth/wasm/test_authorities.py b/testsuite/tests/service_mesh/auth/wasm/test_authorities.py index fd6cc2ad6..fcdcdec20 100644 --- a/testsuite/tests/service_mesh/auth/wasm/test_authorities.py +++ b/testsuite/tests/service_mesh/auth/wasm/test_authorities.py @@ -1,11 +1,13 @@ """Tests wasm authorities filtering""" from urllib.parse import urlsplit + import pytest + +from testsuite import rawobj from testsuite.capabilities import Capability from testsuite.gateways.wasm import ServiceMeshHttpClient from testsuite.utils import blame -from testsuite import rawobj pytestmark = pytest.mark.required_capabilities(Capability.SERVICE_MESH_WASM) diff --git a/testsuite/tests/service_mesh/auth/wasm/test_mapping_rules_sync.py b/testsuite/tests/service_mesh/auth/wasm/test_mapping_rules_sync.py index 82f1315cc..af1242c2e 100644 --- a/testsuite/tests/service_mesh/auth/wasm/test_mapping_rules_sync.py +++ b/testsuite/tests/service_mesh/auth/wasm/test_mapping_rules_sync.py @@ -4,8 +4,9 @@ import backoff import pytest -from testsuite.capabilities import Capability + from testsuite import rawobj +from testsuite.capabilities import Capability from testsuite.utils import blame pytestmark = pytest.mark.required_capabilities(Capability.SERVICE_MESH_WASM) diff --git a/testsuite/tests/system/analytics/test_analytics.py b/testsuite/tests/system/analytics/test_analytics.py index d674c8ff8..8013fac43 100644 --- a/testsuite/tests/system/analytics/test_analytics.py +++ b/testsuite/tests/system/analytics/test_analytics.py @@ -9,8 +9,8 @@ """ import pytest -from testsuite import rawobj -from testsuite import resilient + +from testsuite import rawobj, resilient from testsuite.utils import blame pytestmark = pytest.mark.required_capabilities() diff --git a/testsuite/tests/system/analytics/test_backend_analytics.py b/testsuite/tests/system/analytics/test_backend_analytics.py index 764264625..af24b6e0b 100644 --- a/testsuite/tests/system/analytics/test_backend_analytics.py +++ b/testsuite/tests/system/analytics/test_backend_analytics.py @@ -3,12 +3,12 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import -from testsuite import resilient +from packaging.version import Version + +from testsuite import TESTED_VERSION, rawobj, resilient pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.9')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-3159"), ] diff --git a/testsuite/tests/system/analytics/test_infinite_time_range.py b/testsuite/tests/system/analytics/test_infinite_time_range.py index c10c1f1f7..7398173d5 100644 --- a/testsuite/tests/system/analytics/test_infinite_time_range.py +++ b/testsuite/tests/system/analytics/test_infinite_time_range.py @@ -10,14 +10,14 @@ from datetime import datetime, timedelta, timezone import pytest +from packaging.version import Version from threescale_api.errors import ApiClientError -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION pytestmark = [ pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6649"), - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), ] diff --git a/testsuite/tests/system/mapping/test_mapping_rules.py b/testsuite/tests/system/mapping/test_mapping_rules.py index ecaa3d5bb..dc04241a9 100644 --- a/testsuite/tests/system/mapping/test_mapping_rules.py +++ b/testsuite/tests/system/mapping/test_mapping_rules.py @@ -9,6 +9,7 @@ """ import pytest + from testsuite import rawobj pytestmark = pytest.mark.required_capabilities() diff --git a/testsuite/tests/system/mapping/test_mapping_rules_matching_order_multiple_backends.py b/testsuite/tests/system/mapping/test_mapping_rules_matching_order_multiple_backends.py index fb0509d4c..4e092ecd6 100644 --- a/testsuite/tests/system/mapping/test_mapping_rules_matching_order_multiple_backends.py +++ b/testsuite/tests/system/mapping/test_mapping_rules_matching_order_multiple_backends.py @@ -13,6 +13,8 @@ from testsuite import rawobj, resilient +pytestmark = [pytest.mark.nopersistence] + @pytest.fixture(scope="module") def backends_mapping(custom_backend, private_base_url): diff --git a/testsuite/tests/system/mapping/test_mapping_with_escape_sequence.py b/testsuite/tests/system/mapping/test_mapping_with_escape_sequence.py index a16e864a3..8bb8ce6ea 100644 --- a/testsuite/tests/system/mapping/test_mapping_with_escape_sequence.py +++ b/testsuite/tests/system/mapping/test_mapping_with_escape_sequence.py @@ -4,6 +4,7 @@ """ import pytest + from testsuite import rawobj pytestmark = pytest.mark.required_capabilities() diff --git a/testsuite/tests/system/messages/test_email_accounts.py b/testsuite/tests/system/messages/test_email_accounts.py index 8769e2e07..ae0f3de5b 100644 --- a/testsuite/tests/system/messages/test_email_accounts.py +++ b/testsuite/tests/system/messages/test_email_accounts.py @@ -7,9 +7,10 @@ import os import re + +import backoff import pytest import yaml -import backoff from testsuite import rawobj from testsuite.utils import blame diff --git a/testsuite/tests/system/services/test_api_create_spec.py b/testsuite/tests/system/services/test_api_create_spec.py index 221153b7f..4ef0b4796 100644 --- a/testsuite/tests/system/services/test_api_create_spec.py +++ b/testsuite/tests/system/services/test_api_create_spec.py @@ -3,9 +3,10 @@ """ import pytest + from testsuite import rawobj -from testsuite.utils import blame from testsuite.capabilities import Capability +from testsuite.utils import blame @pytest.fixture(scope="module") diff --git a/testsuite/tests/system/services/test_api_default_spec.py b/testsuite/tests/system/services/test_api_default_spec.py index f46b19d09..fdff7a6e3 100644 --- a/testsuite/tests/system/services/test_api_default_spec.py +++ b/testsuite/tests/system/services/test_api_default_spec.py @@ -3,6 +3,7 @@ """ import pytest + from testsuite.capabilities import Capability diff --git a/testsuite/tests/system/services/test_api_request.py b/testsuite/tests/system/services/test_api_request.py index 481a39d6a..5cf57c0b1 100644 --- a/testsuite/tests/system/services/test_api_request.py +++ b/testsuite/tests/system/services/test_api_request.py @@ -3,9 +3,10 @@ """ import pytest -from testsuite.utils import blame, randomize + from testsuite import rawobj from testsuite.echoed_request import EchoedRequest +from testsuite.utils import blame, randomize @pytest.fixture(scope="module") diff --git a/testsuite/tests/system/test_api_update_public_url_spec.py b/testsuite/tests/system/test_api_update_public_url_spec.py index 14abe4c7d..599a65faa 100644 --- a/testsuite/tests/system/test_api_update_public_url_spec.py +++ b/testsuite/tests/system/test_api_update_public_url_spec.py @@ -3,8 +3,9 @@ """ import pytest -from testsuite.utils import blame + from testsuite.capabilities import Capability +from testsuite.utils import blame pytestmark = pytest.mark.issue("https://issues.jboss.org/browse/THREESCALE-2939") diff --git a/testsuite/tests/system/test_http_routes.py b/testsuite/tests/system/test_http_routes.py index 4420dc571..4f2f17064 100644 --- a/testsuite/tests/system/test_http_routes.py +++ b/testsuite/tests/system/test_http_routes.py @@ -4,16 +4,15 @@ from urllib.parse import urlparse -from packaging.version import Version # noqa # pylint: disable=unused-import - import pytest +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.capabilities import Capability # This test can be done only with system apicast pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.9')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.9"), reason="TESTED_VERSION < Version('2.9')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-3545"), pytest.mark.required_capabilities(Capability.SAME_CLUSTER, Capability.PRODUCTION_GATEWAY), pytest.mark.disruptive, diff --git a/testsuite/tests/system/test_system_redis_secret.py b/testsuite/tests/system/test_system_redis_secret.py index f34257b17..d0ff070a1 100644 --- a/testsuite/tests/system/test_system_redis_secret.py +++ b/testsuite/tests/system/test_system_redis_secret.py @@ -1,8 +1,9 @@ """Tests for MessageBus variables in system-redis secret""" import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from packaging.version import Version + +from testsuite import TESTED_VERSION pytestmark = [ pytest.mark.sandbag, # requires openshift @@ -24,14 +25,14 @@ def system_redis_secret(openshift): return secret -@pytest.mark.skipif("TESTED_VERSION >= Version('2.12')") +@pytest.mark.skipif(TESTED_VERSION >= Version("2.12"), reason="TESTED_VERSION >= Version('2.12')") @pytest.mark.parametrize("key", KEYS) def test_message_bus_secrets(system_redis_secret, key): """test of env variable presence""" assert key in system_redis_secret -@pytest.mark.skipif("TESTED_VERSION < Version('2.12')") +@pytest.mark.skipif(TESTED_VERSION < Version("2.12"), reason="TESTED_VERSION < Version('2.12')") @pytest.mark.parametrize("key", KEYS) def test_message_bus_secrets_missing(system_redis_secret, key): """test of env variable absence""" diff --git a/testsuite/tests/system/test_unique_invoice_id.py b/testsuite/tests/system/test_unique_invoice_id.py index c8e10f20b..457399df1 100644 --- a/testsuite/tests/system/test_unique_invoice_id.py +++ b/testsuite/tests/system/test_unique_invoice_id.py @@ -6,9 +6,11 @@ """ from datetime import date, timedelta + import backoff import pytest -from threescale_api.resources import InvoiceState, Account, ApplicationPlan +from threescale_api.resources import Account, ApplicationPlan, InvoiceState + from testsuite import rawobj from testsuite.utils import blame, blame_desc diff --git a/testsuite/tests/toolbox/conftest.py b/testsuite/tests/toolbox/conftest.py index dc6c415c1..9a7f42245 100644 --- a/testsuite/tests/toolbox/conftest.py +++ b/testsuite/tests/toolbox/conftest.py @@ -1,7 +1,6 @@ "Toolbox conftest" import pytest - from threescale_api import client from testsuite import rawobj diff --git a/testsuite/tests/toolbox/test_activedoc.py b/testsuite/tests/toolbox/test_activedoc.py index b453b897a..40357eab1 100644 --- a/testsuite/tests/toolbox/test_activedoc.py +++ b/testsuite/tests/toolbox/test_activedoc.py @@ -4,10 +4,9 @@ import pytest -from testsuite.toolbox import constants -from testsuite.toolbox import toolbox -from testsuite.utils import blame, blame_desc, randomize from testsuite import rawobj +from testsuite.toolbox import constants, toolbox +from testsuite.utils import blame, blame_desc, randomize SWAGGER_LINK = ( "https://raw.githubusercontent.com/OAI/learn.openapis.org/refs/heads/main/examples/v2.0/json/petstore.json" @@ -58,7 +57,7 @@ def parse_create_command_out(output): # Global variable for metrics' values to check -out_variables = {} +out_variables: dict = {} def test_list1(empty_list, service, my_app_plan, my_activedoc, create_cmd): diff --git a/testsuite/tests/toolbox/test_app_plans.py b/testsuite/tests/toolbox/test_app_plans.py index bae66d682..014ed02cf 100644 --- a/testsuite/tests/toolbox/test_app_plans.py +++ b/testsuite/tests/toolbox/test_app_plans.py @@ -1,18 +1,17 @@ """Tests for Application Plans Toolbox feature""" -import string +import logging import random import re -import logging -import yaml +import string import pytest +import yaml +from testsuite import rawobj from testsuite.config import settings -from testsuite.toolbox import constants -from testsuite.toolbox import toolbox +from testsuite.toolbox import constants, toolbox from testsuite.utils import blame -from testsuite import rawobj pytestmark = [ pytest.mark.xdist_group(name="toolbox"), @@ -60,7 +59,7 @@ def parse_create_command_out(output): # Global variable for metrics' values to check -out_variables = {} +out_variables: dict = {} def test_list1(empty_list, service, my_app_plans, create_cmd): diff --git a/testsuite/tests/toolbox/test_application.py b/testsuite/tests/toolbox/test_application.py index a49fe03c7..8bee0512d 100644 --- a/testsuite/tests/toolbox/test_application.py +++ b/testsuite/tests/toolbox/test_application.py @@ -4,10 +4,9 @@ import pytest -from testsuite.toolbox import constants -from testsuite.toolbox import toolbox -from testsuite.utils import blame from testsuite import rawobj +from testsuite.toolbox import constants, toolbox +from testsuite.utils import blame pytestmark = [ pytest.mark.xdist_group(name="toolbox"), @@ -91,7 +90,7 @@ def parse_create_command_out(output): # Global variable for metrics' values to check -out_variables = {} +out_variables: dict = {} def test_list1(empty_list, my_services, my_applications, create_cmd): diff --git a/testsuite/tests/toolbox/test_backend.py b/testsuite/tests/toolbox/test_backend.py index 5e024535d..a75a0b48d 100644 --- a/testsuite/tests/toolbox/test_backend.py +++ b/testsuite/tests/toolbox/test_backend.py @@ -1,19 +1,19 @@ """Tests for remote Toolbox feature""" -import re import random +import re import string import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version +import testsuite.utils +from testsuite import TESTED_VERSION from testsuite.config import settings from testsuite.toolbox import toolbox -import testsuite.utils -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.7')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.7"), reason="TESTED_VERSION < Version('2.7')"), pytest.mark.xdist_group(name="toolbox"), ] diff --git a/testsuite/tests/toolbox/test_cli.py b/testsuite/tests/toolbox/test_cli.py index a664e00ae..bf3596bf2 100644 --- a/testsuite/tests/toolbox/test_cli.py +++ b/testsuite/tests/toolbox/test_cli.py @@ -1,16 +1,16 @@ """Test Toolbox command `3scale`""" -import re import os +import re import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version +from testsuite import TESTED_VERSION from testsuite.toolbox import toolbox -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.7')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.7"), reason="TESTED_VERSION < Version('2.7')"), ] # removed 'update' as unsupported command diff --git a/testsuite/tests/toolbox/test_method.py b/testsuite/tests/toolbox/test_method.py index a6011e1a4..487ae60ad 100644 --- a/testsuite/tests/toolbox/test_method.py +++ b/testsuite/tests/toolbox/test_method.py @@ -1,15 +1,14 @@ """Tests for working with methods of Toolbox feature""" import re -import pytest -from testsuite.config import settings +import pytest import testsuite from testsuite import rawobj +from testsuite.config import settings +from testsuite.toolbox import constants, toolbox from testsuite.utils import blame -from testsuite.toolbox import constants -from testsuite.toolbox import toolbox pytestmark = [ pytest.mark.xdist_group(name="toolbox"), @@ -65,7 +64,7 @@ def empty_list(service, hits, create_cmd): # Global variable for methods' values to check -out_variables = {} +out_variables: dict = {} def test_list1(empty_list, service, create_cmd): diff --git a/testsuite/tests/toolbox/test_metric.py b/testsuite/tests/toolbox/test_metric.py index 54d239902..cc598bdce 100644 --- a/testsuite/tests/toolbox/test_metric.py +++ b/testsuite/tests/toolbox/test_metric.py @@ -1,15 +1,14 @@ """Tests for working with metrics of Toolbox feature""" import re -import pytest -from testsuite.config import settings +import pytest import testsuite from testsuite import rawobj +from testsuite.config import settings +from testsuite.toolbox import constants, toolbox from testsuite.utils import blame -from testsuite.toolbox import constants -from testsuite.toolbox import toolbox pytestmark = [ pytest.mark.xdist_group(name="toolbox"), @@ -64,7 +63,7 @@ def empty_list(metric_obj, create_cmd): # Global variable for metrics' values to check -out_variables = {} +out_variables: dict = {} def test_list1(empty_list, metric_obj, create_cmd): diff --git a/testsuite/tests/toolbox/test_openapi.py b/testsuite/tests/toolbox/test_openapi.py index c8a50a5a5..dafa89da9 100644 --- a/testsuite/tests/toolbox/test_openapi.py +++ b/testsuite/tests/toolbox/test_openapi.py @@ -9,9 +9,9 @@ import importlib_resources as resources import pytest import yaml -from testsuite.config import settings from testsuite import rawobj +from testsuite.config import settings from testsuite.rhsso.rhsso import OIDCClientAuth from testsuite.toolbox import toolbox from testsuite.utils import blame diff --git a/testsuite/tests/toolbox/test_policies_imp_exp.py b/testsuite/tests/toolbox/test_policies_imp_exp.py index 636f90d54..b1803a872 100644 --- a/testsuite/tests/toolbox/test_policies_imp_exp.py +++ b/testsuite/tests/toolbox/test_policies_imp_exp.py @@ -1,8 +1,9 @@ """Tests for importing service(not product) from CSV Toolbox feature""" +import json import random import string -import json + import pytest from testsuite.config import settings diff --git a/testsuite/tests/toolbox/test_product_backend_exp.py b/testsuite/tests/toolbox/test_product_backend_exp.py index 91176d810..35cdcf7bf 100644 --- a/testsuite/tests/toolbox/test_product_backend_exp.py +++ b/testsuite/tests/toolbox/test_product_backend_exp.py @@ -1,14 +1,15 @@ """Tests for importing/exporting product from/to CRD.""" +import json import random import string -import json + import pytest +from testsuite import rawobj from testsuite.config import settings from testsuite.toolbox import toolbox from testsuite.utils import blame -from testsuite import rawobj pytestmark = [ pytest.mark.xdist_group(name="toolbox"), diff --git a/testsuite/tests/toolbox/test_product_copy.py b/testsuite/tests/toolbox/test_product_copy.py index 453acea82..cae684625 100644 --- a/testsuite/tests/toolbox/test_product_copy.py +++ b/testsuite/tests/toolbox/test_product_copy.py @@ -3,14 +3,14 @@ import re import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version +from testsuite import TESTED_VERSION, rawobj from testsuite.toolbox import toolbox from testsuite.utils import blame, blame_desc -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.7')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.7"), reason="TESTED_VERSION < Version('2.7')"), pytest.mark.xdist_group(name="toolbox"), ] diff --git a/testsuite/tests/toolbox/test_product_update.py b/testsuite/tests/toolbox/test_product_update.py index 1167f3027..ede99975f 100644 --- a/testsuite/tests/toolbox/test_product_update.py +++ b/testsuite/tests/toolbox/test_product_update.py @@ -3,14 +3,14 @@ import re import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version +from testsuite import TESTED_VERSION, rawobj from testsuite.toolbox import toolbox from testsuite.utils import blame, blame_desc -from testsuite import rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.7')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.7"), reason="TESTED_VERSION < Version('2.7')"), pytest.mark.xdist_group(name="toolbox"), ] diff --git a/testsuite/tests/toolbox/test_proxy.py b/testsuite/tests/toolbox/test_proxy.py index 5b51a1f70..bf7e23506 100644 --- a/testsuite/tests/toolbox/test_proxy.py +++ b/testsuite/tests/toolbox/test_proxy.py @@ -1,6 +1,7 @@ """Tests for working with proxy proxy of Toolbox feature""" import json + import pytest from testsuite.toolbox import toolbox diff --git a/testsuite/tests/toolbox/test_proxycfg.py b/testsuite/tests/toolbox/test_proxycfg.py index cab1e63a1..c64329f7b 100644 --- a/testsuite/tests/toolbox/test_proxycfg.py +++ b/testsuite/tests/toolbox/test_proxycfg.py @@ -1,7 +1,8 @@ """Tests for working with proxy configurations of Toolbox feature""" -import re import json +import re + import pytest from testsuite import rawobj @@ -42,7 +43,7 @@ def hits(service): # Global variable for proxy configurations' values to check -out_variables = {} +out_variables: dict = {} def test_list_staging1(service, empty_list_staging, create_cmd): diff --git a/testsuite/tests/toolbox/test_remote.py b/testsuite/tests/toolbox/test_remote.py index 2f45d78c3..310f0d75b 100644 --- a/testsuite/tests/toolbox/test_remote.py +++ b/testsuite/tests/toolbox/test_remote.py @@ -5,7 +5,6 @@ import pytest from testsuite.config import settings - from testsuite.toolbox import toolbox pytestmark = [ diff --git a/testsuite/tests/toolbox/test_service.py b/testsuite/tests/toolbox/test_service.py index f4f52cd82..82b0c35bd 100644 --- a/testsuite/tests/toolbox/test_service.py +++ b/testsuite/tests/toolbox/test_service.py @@ -4,8 +4,7 @@ import pytest -from testsuite.toolbox import constants -from testsuite.toolbox import toolbox +from testsuite.toolbox import constants, toolbox from testsuite.utils import randomize pytestmark = [ @@ -37,7 +36,7 @@ def parse_create_command_out(output): # Global variable for metrics' values to check -out_variables = {} +out_variables: dict = {} def test_list1(empty_list, service, create_cmd): diff --git a/testsuite/tests/toolbox/test_service_csv.py b/testsuite/tests/toolbox/test_service_csv.py index 400ffdca5..4cfecf5a6 100644 --- a/testsuite/tests/toolbox/test_service_csv.py +++ b/testsuite/tests/toolbox/test_service_csv.py @@ -2,8 +2,9 @@ import os import random -import string import re +import string + import pytest from testsuite.config import settings diff --git a/testsuite/tests/tools/conftest.py b/testsuite/tests/tools/conftest.py index 01f1dce6f..495985218 100644 --- a/testsuite/tests/tools/conftest.py +++ b/testsuite/tests/tools/conftest.py @@ -1,6 +1,7 @@ """Tools conftest""" import json + import pytest from testsuite.utils import get_results_dir_path diff --git a/testsuite/tests/tools/test_tool_availability.py b/testsuite/tests/tools/test_tool_availability.py index 7db3982ee..900d0dd81 100644 --- a/testsuite/tests/tools/test_tool_availability.py +++ b/testsuite/tests/tools/test_tool_availability.py @@ -2,8 +2,8 @@ import json -import requests import pytest +import requests from testsuite.rhsso import RHSSOServiceConfiguration diff --git a/testsuite/tests/ui/__init__.py b/testsuite/tests/ui/__init__.py index fc038fdf2..e1e609501 100644 --- a/testsuite/tests/ui/__init__.py +++ b/testsuite/tests/ui/__init__.py @@ -1,6 +1,6 @@ """UI tests module""" -from typing import List, Dict +from typing import Dict, List class Sessions: diff --git a/testsuite/tests/ui/apiap/test_config_version_update_azp_values.py b/testsuite/tests/ui/apiap/test_config_version_update_azp_values.py index eddbbac46..58db4ddcf 100644 --- a/testsuite/tests/ui/apiap/test_config_version_update_azp_values.py +++ b/testsuite/tests/ui/apiap/test_config_version_update_azp_values.py @@ -4,7 +4,9 @@ import pytest -from testsuite.ui.views.admin.product.integration.configuration import ProductConfigurationView +from testsuite.ui.views.admin.product.integration.configuration import ( + ProductConfigurationView, +) from testsuite.ui.views.admin.product.integration.settings import ProductSettingsView diff --git a/testsuite/tests/ui/apiap/test_dashboard.py b/testsuite/tests/ui/apiap/test_dashboard.py index 94b90a14b..2defdf057 100644 --- a/testsuite/tests/ui/apiap/test_dashboard.py +++ b/testsuite/tests/ui/apiap/test_dashboard.py @@ -7,7 +7,9 @@ from testsuite.ui.views.admin.audience.account import AccountsView from testsuite.ui.views.admin.audience.application import ApplicationsView from testsuite.ui.views.admin.audience.billing import BillingView -from testsuite.ui.views.admin.audience.developer_portal import DeveloperPortalContentView +from testsuite.ui.views.admin.audience.developer_portal import ( + DeveloperPortalContentView, +) from testsuite.ui.views.admin.audience.messages import MessagesView from testsuite.ui.views.admin.backend import BackendsView from testsuite.ui.views.admin.backend.backend import BackendNewView diff --git a/testsuite/tests/ui/apiap/test_product.py b/testsuite/tests/ui/apiap/test_product.py index e7a6493a6..4f585bd88 100644 --- a/testsuite/tests/ui/apiap/test_product.py +++ b/testsuite/tests/ui/apiap/test_product.py @@ -2,12 +2,17 @@ import pytest -from testsuite.ui.views.admin.product.product import ProductEditView +from testsuite import rawobj, resilient from testsuite.ui.views.admin.product.application import ApplicationPlanDetailView +from testsuite.ui.views.admin.product.integration.backends import ( + ProductAddBackendView, + ProductBackendsView, +) +from testsuite.ui.views.admin.product.integration.configuration import ( + ProductConfigurationView, +) from testsuite.ui.views.admin.product.integration.settings import ProductSettingsView -from testsuite.ui.views.admin.product.integration.configuration import ProductConfigurationView -from testsuite.ui.views.admin.product.integration.backends import ProductBackendsView, ProductAddBackendView -from testsuite import rawobj, resilient +from testsuite.ui.views.admin.product.product import ProductEditView from testsuite.utils import blame pytestmark = pytest.mark.usefixtures("login") diff --git a/testsuite/tests/ui/apiap/test_public_base_url.py b/testsuite/tests/ui/apiap/test_public_base_url.py index 7f00d0d0b..46a8eab96 100644 --- a/testsuite/tests/ui/apiap/test_public_base_url.py +++ b/testsuite/tests/ui/apiap/test_public_base_url.py @@ -1,15 +1,15 @@ """Test for Public Base URLs as localhost""" import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version from widgetastic.widget import Text -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.ui.views.admin.product.integration.settings import ProductSettingsView pytestmark = [ pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-7149"), - pytest.mark.skipif("TESTED_VERSION < Version('2.12')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.12"), reason="TESTED_VERSION < Version('2.12')"), ] diff --git a/testsuite/tests/ui/applications/test_application_plans.py b/testsuite/tests/ui/applications/test_application_plans.py index 8c1e750e4..4752e8c16 100644 --- a/testsuite/tests/ui/applications/test_application_plans.py +++ b/testsuite/tests/ui/applications/test_application_plans.py @@ -1,10 +1,9 @@ """Tests of applications plans""" import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import -from testsuite import rawobj +from testsuite import TESTED_VERSION, rawobj from testsuite.ui.views.admin.product.application import ApplicationPlansView from testsuite.utils import blame @@ -25,7 +24,7 @@ def test_app_plan_create(custom_ui_app_plan, request, service): @pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-825") -@pytest.mark.skipif("TESTED_VERSION < Version('2.13')") +@pytest.mark.skipif(TESTED_VERSION < Version("2.13"), reason="TESTED_VERSION < Version('2.13')") def test_default_app_plan_change(request, service, custom_app_plan, navigator): """ Test of default application plan change: @@ -54,7 +53,7 @@ def test_default_app_plan_change(request, service, custom_app_plan, navigator): @pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-8979") -@pytest.mark.skipif("TESTED_VERSION < Version('2.13')") +@pytest.mark.skipif(TESTED_VERSION < Version("2.13"), reason="TESTED_VERSION < Version('2.13')") def test_unset_default_app_plan(request, service, custom_app_plan, navigator): """ Test unset default application plan: diff --git a/testsuite/tests/ui/auth/conftest.py b/testsuite/tests/ui/auth/conftest.py index 08b99b235..84eb3b3e0 100644 --- a/testsuite/tests/ui/auth/conftest.py +++ b/testsuite/tests/ui/auth/conftest.py @@ -8,8 +8,8 @@ from testsuite import resilient from testsuite.ui.views.admin.settings.sso_integrations import ( NewSSOIntegrationView, - SSOIntegrationEditView, SSOIntegrationDetailView, + SSOIntegrationEditView, ) from testsuite.ui.views.auth import Auth0View, RhssoView diff --git a/testsuite/tests/ui/auth/test_login_recaptcha.py b/testsuite/tests/ui/auth/test_login_recaptcha.py new file mode 100644 index 000000000..48f401f72 --- /dev/null +++ b/testsuite/tests/ui/auth/test_login_recaptcha.py @@ -0,0 +1,75 @@ +"""Test for login into admin portal with bot protection (recaptcha) enabled""" + +import pytest +from packaging.version import Version + +from testsuite import TESTED_VERSION, settings +from testsuite.ui.views.admin.login import LoginView, RequestAdminPasswordView +from testsuite.ui.views.admin.settings.bot_protection import AdminBotProtection + +pytestmark = [ + pytest.mark.usefixtures("login"), + pytest.mark.usefixtures("bot_protection_setup"), + pytest.mark.issue("https://redhat.atlassian.net/browse/THREESCALE-765"), + pytest.mark.skipif(TESTED_VERSION < Version("2.16"), reason="TESTED_VERSION < Version('2.16')"), +] + + +@pytest.fixture(scope="module") +def bot_protection_setup(navigator, browser): + """ + Enables admin portal bot protection via UI, + then clears session so subsequent tests see the unauthenticated login page. + Requires recaptcha keys to be configured in 3scale settings. + Session cookies are saved before deletion and restored in teardown to avoid + circular dependency (recaptcha blocks selenium login during teardown). + """ + bot_page = navigator.navigate(AdminBotProtection) + bot_page.enable_protection() + saved_cookies = browser.selenium.get_cookies() + browser.selenium.delete_all_cookies() + + yield + + browser.selenium.get(settings["threescale"]["admin"]["url"]) + for cookie in saved_cookies: + browser.selenium.add_cookie(cookie) + browser.selenium.refresh() + navigator.navigate(AdminBotProtection).disable_protection() + + +def test_admin_login_blocked_by_recaptcha(navigator): + """ + Test + - Navigates to the admin portal login page + - Waits for reCAPTCHA to load and generate a token + - Attempts to log in with valid credentials + - Asserts that login is rejected due to low reCAPTCHA score from automated browser + """ + login_page = navigator.open(LoginView, url=settings["threescale"]["admin"]["url"], wait_displayed=False) + assert login_page.recaptcha.is_displayed, "Recaptcha was not found on the admin portal login page" + login_page.browser.execute_script( # hack to force reCAPTCHA V3 get bad score + "window.grecaptcha.execute = () => Promise.resolve('');" + ) + login_page.login_widget.do_login( + settings["threescale"]["admin"]["username"], settings["threescale"]["admin"]["password"] + ) + assert login_page.error_message.is_displayed, "Expected reCAPTCHA error message to be displayed" + + +@pytest.mark.xfail # not implemented yet +def test_admin_forgot_password_blocked_by_recaptcha(navigator): + """ + Test + - Navigates to the admin portal forgot password page + - Overrides reCAPTCHA token to force rejection + - Submits a password reset request + - Asserts that the request is rejected due to invalid reCAPTCHA token + """ + forgot_pass = navigator.open(RequestAdminPasswordView, url=settings["threescale"]["admin"]["url"]) + assert forgot_pass.recaptcha.is_displayed, "Recaptcha was not found on the admin portal forgot password page" + forgot_pass.browser.execute_script( # hack to force reCAPTCHA V3 get bad score + "window.grecaptcha.execute = () => Promise.resolve('');" + ) + forgot_pass.reset_password(settings["threescale"]["admin"]["username"]) + assert forgot_pass.error_message.is_displayed, "Expected reCAPTCHA error message to be displayed" diff --git a/testsuite/tests/ui/billing/braintree/conftest.py b/testsuite/tests/ui/billing/braintree/conftest.py index 469c1293b..3ed427456 100644 --- a/testsuite/tests/ui/billing/braintree/conftest.py +++ b/testsuite/tests/ui/billing/braintree/conftest.py @@ -2,8 +2,8 @@ from datetime import datetime -import pytest import openshift_client as oc +import pytest from testsuite.billing import Braintree from testsuite.ui.objects import CreditCard @@ -24,13 +24,14 @@ def require_braintree_patch(openshift): @pytest.fixture(scope="session") -def braintree(testconfig): +def braintree(testconfig, threescale): """Braintree API""" braintree_credentials = testconfig["braintree"] merchant_id = braintree_credentials["merchant_id"] public_key = braintree_credentials["public_key"] private_key = braintree_credentials["private_key"] - return Braintree(merchant_id, public_key, private_key) + provider_account_id = threescale.provider_accounts.fetch().entity_id + return Braintree(merchant_id, public_key, private_key, provider_account_id) @pytest.fixture(scope="module", autouse=True) diff --git a/testsuite/tests/ui/billing/braintree/test_invoice_payment.py b/testsuite/tests/ui/billing/braintree/test_invoice_payment.py index cbf07310a..56c6af0b6 100644 --- a/testsuite/tests/ui/billing/braintree/test_invoice_payment.py +++ b/testsuite/tests/ui/billing/braintree/test_invoice_payment.py @@ -15,7 +15,7 @@ def card_setup(custom_card): def normalize_url(url): """Invoice url need to be changed from internal to external form""" - for rep in (("3scale-admin", "3scale"), ("/api/", "/admin/account/")): + for rep in (("-admin.", "."), ("/api/", "/admin/account/")): url = url.replace(*rep) return url @@ -28,11 +28,11 @@ def test_no_sca_ui_invoice(braintree, ui_invoice, account): assert invoice_view.state_field.text == "State Paid" -def test_mail_completed_payment(invoice, mailhog_client): +def test_mail_completed_payment(provider_account, invoice, mailhog_client): """Tests mail notification about successful payment""" invoice.charge() mailhog_client.assert_message_received( - subject="Provider Name API - Payment completed", + subject=f"{provider_account['org_name']} API - Payment completed", content=f"successfully completed your monthly payment for our service of USD {invoice.entity['cost']}0.\r\n\r\n" f"Your invoice is available online at:\r\n\r\n{normalize_url(invoice.url)}", ) diff --git a/testsuite/tests/ui/billing/conftest.py b/testsuite/tests/ui/billing/conftest.py index e1a8591f4..7f094494f 100644 --- a/testsuite/tests/ui/billing/conftest.py +++ b/testsuite/tests/ui/billing/conftest.py @@ -5,7 +5,10 @@ from testsuite import rawobj from testsuite.ui.objects import BillingAddress -from testsuite.ui.views.admin.audience.account import InvoiceDetailView, AccountInvoicesView +from testsuite.ui.views.admin.audience.account import ( + AccountInvoicesView, + InvoiceDetailView, +) from testsuite.utils import randomize diff --git a/testsuite/tests/ui/billing/stripe/conftest.py b/testsuite/tests/ui/billing/stripe/conftest.py index d1a0d3247..7f6b34911 100644 --- a/testsuite/tests/ui/billing/stripe/conftest.py +++ b/testsuite/tests/ui/billing/stripe/conftest.py @@ -20,9 +20,10 @@ def gateway_setup(custom_admin_login, navigator, testconfig): @pytest.fixture(scope="session") -def stripe(testconfig): +def stripe(testconfig, threescale): """Stripe API""" - return Stripe(testconfig["stripe"]["api_key"]) + provider_account_id = threescale.provider_accounts.fetch().entity_id + return Stripe(testconfig["stripe"]["api_key"], provider_account_id) @pytest.fixture(scope="module") diff --git a/testsuite/tests/ui/conftest.py b/testsuite/tests/ui/conftest.py index 8a90a3fab..7c0b7ff61 100644 --- a/testsuite/tests/ui/conftest.py +++ b/testsuite/tests/ui/conftest.py @@ -12,26 +12,28 @@ import pytest import pytest_html from auth0.management import Auth0 +from PIL import Image from selenium.common import InvalidSessionIdException, WebDriverException from threescale_api.errors import ApiClientError from threescale_api.resources import Account, ApplicationPlan, Service -from PIL import Image from testsuite import rawobj, resilient from testsuite.auth0 import auth0_token from testsuite.config import settings from testsuite.ui.browser import ThreeScaleBrowser from testsuite.ui.navigation import Navigator -from testsuite.ui.views.admin.foundation import DashboardView from testsuite.ui.views.admin.audience.account import AccountNewView, AccountsView -from testsuite.ui.views.admin.audience.application import ApplicationNewView, ApplicationsView -from testsuite.ui.views.admin.product.product import ProductsView +from testsuite.ui.views.admin.audience.application import ( + ApplicationNewView, + ApplicationsView, +) from testsuite.ui.views.admin.backend.backend import BackendNewView +from testsuite.ui.views.admin.foundation import DashboardView from testsuite.ui.views.admin.login import LoginView from testsuite.ui.views.admin.product.application import ApplicationPlanNewView -from testsuite.ui.views.admin.product.product import ProductNewView +from testsuite.ui.views.admin.product.product import ProductNewView, ProductsView from testsuite.ui.views.devel.login import LoginView as DeveloperLoginView -from testsuite.ui.views.master.audience.tenant import TenantNewView, TenantDetailView +from testsuite.ui.views.master.audience.tenant import TenantDetailView, TenantNewView from testsuite.ui.views.master.login import MasterLoginView from testsuite.ui.webdriver import ThreescaleWebdriver from testsuite.utils import blame, get_results_dir_path diff --git a/testsuite/tests/ui/devel/auth/test_login_auth0.py b/testsuite/tests/ui/devel/auth/test_login_auth0.py index b48740795..f9ab9fce0 100644 --- a/testsuite/tests/ui/devel/auth/test_login_auth0.py +++ b/testsuite/tests/ui/devel/auth/test_login_auth0.py @@ -3,10 +3,10 @@ import pytest from testsuite.ui.views.admin.audience.developer_portal.sso_integrations import ( - Auth0IntegrationEditView, Auth0IntegrationDetailView, + Auth0IntegrationEditView, ) -from testsuite.ui.views.devel import SignUpView, BaseDevelView +from testsuite.ui.views.devel import BaseDevelView, SignUpView @pytest.fixture(scope="module") diff --git a/testsuite/tests/ui/devel/auth/test_login_recaptcha.py b/testsuite/tests/ui/devel/auth/test_login_recaptcha.py index 3a8e8e37a..d715c51d2 100644 --- a/testsuite/tests/ui/devel/auth/test_login_recaptcha.py +++ b/testsuite/tests/ui/devel/auth/test_login_recaptcha.py @@ -1,11 +1,15 @@ """Test for login into devel portal with spam protection enabled""" import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import settings, rawobj, TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION, rawobj, settings from testsuite.ui.views.admin.audience.developer_portal import BotProtection -from testsuite.ui.views.devel.login import BasicSignUpView, LoginView, ForgotPasswordView +from testsuite.ui.views.devel.login import ( + BasicSignUpView, + ForgotPasswordView, + LoginView, +) from testsuite.utils import blame, warn_and_skip # requires special setup, internet access @@ -97,7 +101,7 @@ def test_devel_forgot_password_recaptcha(custom_account, navigator, params): @pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-10579") -@pytest.mark.skipif("TESTED_VERSION < Version('2.15')") +@pytest.mark.skipif(TESTED_VERSION < Version("2.15"), reason="TESTED_VERSION < Version('2.15')") def test_devel_login_recaptcha(custom_account, navigator, params): """ Test diff --git a/testsuite/tests/ui/devel/auth/test_login_rhsso.py b/testsuite/tests/ui/devel/auth/test_login_rhsso.py index ed2c10ea7..dc32afd12 100644 --- a/testsuite/tests/ui/devel/auth/test_login_rhsso.py +++ b/testsuite/tests/ui/devel/auth/test_login_rhsso.py @@ -3,8 +3,8 @@ import pytest from testsuite.ui.views.admin.audience.developer_portal.sso_integrations import ( - RHSSOIntegrationEditView, RHSSOIntegrationDetailView, + RHSSOIntegrationEditView, ) from testsuite.ui.views.devel import BaseDevelView diff --git a/testsuite/tests/ui/devel/test_devel_sections.py b/testsuite/tests/ui/devel/test_devel_sections.py index ec7760a64..70c9de04e 100644 --- a/testsuite/tests/ui/devel/test_devel_sections.py +++ b/testsuite/tests/ui/devel/test_devel_sections.py @@ -1,20 +1,27 @@ """Test for developer portal sections""" +import backoff import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.ui.views.admin.audience.account import AccountUserGroupView from testsuite.ui.views.admin.audience.developer_portal import ( - DeveloperPortalGroupNewView, CMSEditPageView, CMSNewPageView, CMSNewSectionView, + DeveloperPortalGroupNewView, DeveloperPortalGroupView, ) from testsuite.ui.views.common.foundation import NotFoundView from testsuite.utils import blame +pytestmark = [ + pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-9020"), + pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-836"), + pytest.mark.skipif(TESTED_VERSION < Version("2.14-dev"), reason="Requires 3scale >= 2.14"), +] + @pytest.fixture(scope="module") def dev_portal_section(navigator, request, threescale): @@ -67,9 +74,10 @@ def cleanup(): view.update([group_name]) +@backoff.on_exception(backoff.fibo, AssertionError, max_tries=5, jitter=None) @pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-9020") @pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-836") -@pytest.mark.skipif("TESTED_VERSION < Version('2.14-dev')") +@pytest.mark.skipif(TESTED_VERSION < Version("2.14-dev"), reason="TESTED_VERSION < Version('2.14-dev')") @pytest.mark.usefixtures("dev_portal_group") @pytest.mark.usefixtures("login") def test_dev_portal_sections(account, custom_devel_login, browser, testconfig, dev_portal_page): @@ -85,11 +93,13 @@ def test_dev_portal_sections(account, custom_devel_login, browser, testconfig, d - Assert that this account hasn't access to this page """ custom_devel_login(account=account) + browser.url = testconfig["threescale"]["devel"]["url"] + dev_portal_page assert browser.element(".//h1").accessible_name == "Test" custom_devel_login(name="john", password="123456", fresh=True) + browser.url = testconfig["threescale"]["devel"]["url"] + dev_portal_page assert NotFoundView(browser).is_displayed diff --git a/testsuite/tests/ui/devel/test_devel_smoke.py b/testsuite/tests/ui/devel/test_devel_smoke.py index bffe6fb15..994695337 100644 --- a/testsuite/tests/ui/devel/test_devel_smoke.py +++ b/testsuite/tests/ui/devel/test_devel_smoke.py @@ -4,7 +4,7 @@ from testsuite import settings from testsuite.ui.views.admin.audience import BaseAudienceView -from testsuite.ui.views.devel import BaseDevelView, AccessView, LandingView +from testsuite.ui.views.devel import AccessView, BaseDevelView, LandingView @pytest.fixture(scope="module") diff --git a/testsuite/tests/ui/mail_and_messages/test_account_messages.py b/testsuite/tests/ui/mail_and_messages/test_account_messages.py index 70e4ea177..e7a53053d 100644 --- a/testsuite/tests/ui/mail_and_messages/test_account_messages.py +++ b/testsuite/tests/ui/mail_and_messages/test_account_messages.py @@ -7,10 +7,15 @@ from testsuite import rawobj from testsuite.config import settings from testsuite.ui.views.admin.foundation import BaseAdminView -from testsuite.ui.views.admin.login import RequestAdminPasswordView, LoginView, ResetPasswordView +from testsuite.ui.views.admin.login import ( + LoginView, + RequestAdminPasswordView, + ResetPasswordView, +) from testsuite.ui.views.devel import Navbar -from testsuite.ui.views.devel.login import ForgotPasswordView, LoginView as DevelLoginView -from testsuite.utils import randomize, blame +from testsuite.ui.views.devel.login import ForgotPasswordView +from testsuite.ui.views.devel.login import LoginView as DevelLoginView +from testsuite.utils import blame, randomize @pytest.fixture(scope="module") @@ -53,7 +58,7 @@ def test_admin_forgotten_password( mailhog_client.assert_message_received(subject="Password Recovery", receiver=mail, expected_count=1) - message = mailhog_client.find_message(subject="Password Recovery", receiver=mail) + message = mailhog_client.find_messages(subject="Password Recovery", receiver=mail) reset_link = re.search(r"(?Phttps?://\S+)", message["items"][0]["Content"]["Body"]).group("url") page = navigator.open(ResetPasswordView, url=reset_link, exact=True) @@ -93,7 +98,7 @@ def test_developer_forgotten_password( expected_count=1, ) - message = mailhog_client.find_message( + message = mailhog_client.find_messages( subject=f"{provider_account.entity_name} Lost password recovery. (Valid for 24 hours)", receiver=mail ) diff --git a/testsuite/tests/ui/mail_and_messages/test_automatic_mails.py b/testsuite/tests/ui/mail_and_messages/test_automatic_mails.py index d8ef5ae07..e8f88a234 100644 --- a/testsuite/tests/ui/mail_and_messages/test_automatic_mails.py +++ b/testsuite/tests/ui/mail_and_messages/test_automatic_mails.py @@ -1,8 +1,8 @@ """Test of automatic mails functionality in UI""" import re -import pytest +import pytest from testsuite.ui.views.admin.audience.account import AccountInvitationNewView from testsuite.ui.views.devel.login import InvitationSignupView diff --git a/testsuite/tests/ui/mail_and_messages/test_email_application.py b/testsuite/tests/ui/mail_and_messages/test_email_application.py index 27bed3a75..801e1a708 100644 --- a/testsuite/tests/ui/mail_and_messages/test_email_application.py +++ b/testsuite/tests/ui/mail_and_messages/test_email_application.py @@ -4,10 +4,9 @@ from threescale_api.resources import Service from testsuite import rawobj -from testsuite.utils import blame - from testsuite.ui.views.admin.audience.application import ApplicationDetailView from testsuite.ui.views.devel.applications import DevelApplicationDetailView +from testsuite.utils import blame pytestmark = pytest.mark.usefixtures("login") diff --git a/testsuite/tests/ui/mail_and_messages/test_mail_to_suspended_user.py b/testsuite/tests/ui/mail_and_messages/test_mail_to_suspended_user.py index 5d8bb4a47..a1493820b 100644 --- a/testsuite/tests/ui/mail_and_messages/test_mail_to_suspended_user.py +++ b/testsuite/tests/ui/mail_and_messages/test_mail_to_suspended_user.py @@ -1,9 +1,9 @@ """Test that system is not sending mail notification to suspended users""" import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.ui.views.admin.settings.user import UserDetailView from testsuite.utils import blame @@ -35,7 +35,7 @@ def provider_account_user(navigator, provider_account_user): @pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-8903") @pytest.mark.usefixtures("login") -@pytest.mark.skipif("TESTED_VERSION < Version('2.14-dev')") +@pytest.mark.skipif(TESTED_VERSION < Version("2.14-dev"), reason="TESTED_VERSION < Version('2.14-dev')") def test_mail_to_suspended_user(provider_account_user, ui_account, mailhog_client): """ Test: diff --git a/testsuite/tests/ui/mail_and_messages/test_message_counter.py b/testsuite/tests/ui/mail_and_messages/test_message_counter.py index 87f018ef3..8ae1f50d0 100644 --- a/testsuite/tests/ui/mail_and_messages/test_message_counter.py +++ b/testsuite/tests/ui/mail_and_messages/test_message_counter.py @@ -1,9 +1,9 @@ """Test of message counters in dashboard main-section tabs""" import pytest +from packaging.version import Version -from packaging.version import Version # noqa # pylint: disable=unused-import -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.ui.views.admin.audience.messages import MessagesView from testsuite.ui.views.admin.foundation import DashboardView from testsuite.ui.views.devel.messages import ComposeView @@ -27,7 +27,7 @@ def send_message_from_devel(navigator, subject, body): # pylint: disable=too-many-arguments -@pytest.mark.skipif("TESTED_VERSION < Version('2.15')") +@pytest.mark.skipif(TESTED_VERSION < Version("2.15"), reason="TESTED_VERSION < Version('2.15')") @pytest.mark.usefixtures("login", "application", "service") def test_message_counter(custom_devel_login, custom_admin_login, account, navigator): """ diff --git a/testsuite/tests/ui/mail_and_messages/test_messages.py b/testsuite/tests/ui/mail_and_messages/test_messages.py index 116fbe6eb..649cec162 100644 --- a/testsuite/tests/ui/mail_and_messages/test_messages.py +++ b/testsuite/tests/ui/mail_and_messages/test_messages.py @@ -2,10 +2,10 @@ import pytest -from testsuite.ui.views.admin.audience.messages import MessagesView, ComposeMessageView -from testsuite.utils import blame -from testsuite.ui.views.devel.messages import InboxView, ComposeView from testsuite.ui.views.admin.audience.application import ApplicationsView +from testsuite.ui.views.admin.audience.messages import ComposeMessageView, MessagesView +from testsuite.ui.views.devel.messages import ComposeView, InboxView +from testsuite.utils import blame @pytest.fixture() diff --git a/testsuite/tests/ui/master/test_tenant.py b/testsuite/tests/ui/master/test_tenant.py index b93b96c57..40648386b 100644 --- a/testsuite/tests/ui/master/test_tenant.py +++ b/testsuite/tests/ui/master/test_tenant.py @@ -5,13 +5,17 @@ import pytest from testsuite import resilient -from testsuite.ui.views.admin.login import LoginView +from testsuite.ui.utils import assert_displayed_in_new_tab from testsuite.ui.views.admin.foundation import DashboardView +from testsuite.ui.views.admin.login import LoginView from testsuite.ui.views.common.foundation import NotFoundView -from testsuite.utils import blame -from testsuite.ui.utils import assert_displayed_in_new_tab -from testsuite.ui.views.master.audience.tenant import TenantDetailView, TenantEditView, TenantsView from testsuite.ui.views.devel import LandingView +from testsuite.ui.views.master.audience.tenant import ( + TenantDetailView, + TenantEditView, + TenantsView, +) +from testsuite.utils import blame pytestmark = pytest.mark.usefixtures("master_login") diff --git a/testsuite/tests/ui/oas/test_active_docs_v2.py b/testsuite/tests/ui/oas/test_active_docs_v2.py index 2ec32a665..362b2b6f3 100644 --- a/testsuite/tests/ui/oas/test_active_docs_v2.py +++ b/testsuite/tests/ui/oas/test_active_docs_v2.py @@ -3,13 +3,13 @@ from string import Template from urllib.parse import urlsplit -import pytest import importlib_resources as resources +import pytest from testsuite import rawobj -from testsuite.utils import blame from testsuite.ui.views.admin.audience.developer_portal import ActiveDocsNewView from testsuite.ui.views.admin.product.active_docs import ActiveDocsDetailView +from testsuite.utils import blame @pytest.fixture() diff --git a/testsuite/tests/ui/oas/test_active_docs_v3.py b/testsuite/tests/ui/oas/test_active_docs_v3.py index 14778c781..64f191d7f 100644 --- a/testsuite/tests/ui/oas/test_active_docs_v3.py +++ b/testsuite/tests/ui/oas/test_active_docs_v3.py @@ -7,7 +7,10 @@ from threescale_api.resources import Service from testsuite import rawobj -from testsuite.ui.views.admin.product.active_docs import ActiveDocsDetailView, ActiveDocsView +from testsuite.ui.views.admin.product.active_docs import ( + ActiveDocsDetailView, + ActiveDocsView, +) from testsuite.utils import blame pytestmark = pytest.mark.usefixtures("login") diff --git a/testsuite/tests/ui/oas/test_api_key_autocomplete.py b/testsuite/tests/ui/oas/test_api_key_autocomplete.py index 3c6e00a67..904242ccd 100644 --- a/testsuite/tests/ui/oas/test_api_key_autocomplete.py +++ b/testsuite/tests/ui/oas/test_api_key_autocomplete.py @@ -3,7 +3,10 @@ import importlib_resources as resources import pytest -from testsuite.ui.views.admin.audience.developer_portal import CMSEditPageView, CMSNewPageView +from testsuite.ui.views.admin.audience.developer_portal import ( + CMSEditPageView, + CMSNewPageView, +) from testsuite.ui.views.devel import DocsView from testsuite.utils import blame diff --git a/testsuite/tests/ui/oas/test_multiple_oas_docs.py b/testsuite/tests/ui/oas/test_multiple_oas_docs.py index dafe8b791..54015530e 100644 --- a/testsuite/tests/ui/oas/test_multiple_oas_docs.py +++ b/testsuite/tests/ui/oas/test_multiple_oas_docs.py @@ -3,7 +3,11 @@ import importlib_resources as resources import pytest -from testsuite.ui.views.admin.audience.developer_portal import CMSEditPageView, CMSNewPageView, ActiveDocsNewView +from testsuite.ui.views.admin.audience.developer_portal import ( + ActiveDocsNewView, + CMSEditPageView, + CMSNewPageView, +) from testsuite.ui.views.devel import DocsView from testsuite.utils import blame diff --git a/testsuite/tests/ui/policies/test_policies.py b/testsuite/tests/ui/policies/test_policies.py index 7cf10ff21..4b6c1db73 100644 --- a/testsuite/tests/ui/policies/test_policies.py +++ b/testsuite/tests/ui/policies/test_policies.py @@ -3,8 +3,14 @@ from collections import Counter import pytest -from testsuite.ui.views.admin.product.integration.configuration import ProductConfigurationView -from testsuite.ui.views.admin.product.integration.policies import ProductPoliciesView, Policies + +from testsuite.ui.views.admin.product.integration.configuration import ( + ProductConfigurationView, +) +from testsuite.ui.views.admin.product.integration.policies import ( + Policies, + ProductPoliciesView, +) pytestmark = pytest.mark.usefixtures("login") diff --git a/testsuite/tests/ui/policies/test_referrer_policy.py b/testsuite/tests/ui/policies/test_referrer_policy.py index 8b9145811..0ed19fa1b 100644 --- a/testsuite/tests/ui/policies/test_referrer_policy.py +++ b/testsuite/tests/ui/policies/test_referrer_policy.py @@ -3,9 +3,14 @@ import pytest from testsuite.ui.views.admin.audience.application import ApplicationDetailView -from testsuite.ui.views.admin.product.integration.policies import ProductPoliciesView, Policies -from testsuite.ui.views.admin.product.integration.configuration import ProductConfigurationView from testsuite.ui.views.admin.product.application import UsageRulesView +from testsuite.ui.views.admin.product.integration.configuration import ( + ProductConfigurationView, +) +from testsuite.ui.views.admin.product.integration.policies import ( + Policies, + ProductPoliciesView, +) @pytest.fixture(scope="module", autouse=True) diff --git a/testsuite/tests/ui/policies/test_tls_termination_policy_in_ui.py b/testsuite/tests/ui/policies/test_tls_termination_policy_in_ui.py index bdd393b09..aaa49ce3a 100644 --- a/testsuite/tests/ui/policies/test_tls_termination_policy_in_ui.py +++ b/testsuite/tests/ui/policies/test_tls_termination_policy_in_ui.py @@ -4,34 +4,38 @@ import pytest import requests -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import -from testsuite import rawobj +from testsuite import TESTED_VERSION, rawobj from testsuite.capabilities import Capability -from testsuite.ui.views.admin.product.integration.configuration import ProductConfigurationView -from testsuite.ui.views.admin.product.integration.policies import ProductPoliciesView, TlsTerminationPolicyView -from testsuite.utils import blame # Imports for TLS fixtures # noqa # pylint: disable=unused-import from testsuite.tests.apicast.policy.tls.conftest import ( - require_openshift, - staging_gateway, - mount_certificate_secret, - valid_authority, certificate, create_cert, - server_authority, + gateway_environment, + gateway_options, manager, + mount_certificate_secret, + require_openshift, + server_authority, + staging_gateway, superdomain, - gateway_options, - gateway_environment, + valid_authority, +) +from testsuite.ui.views.admin.product.integration.configuration import ( + ProductConfigurationView, ) +from testsuite.ui.views.admin.product.integration.policies import ( + ProductPoliciesView, + TlsTerminationPolicyView, +) +from testsuite.utils import blame pytestmark = [ pytest.mark.sandbag, # TLS requires pretty specific complex setup - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6390"), pytest.mark.usefixtures("login"), ] diff --git a/testsuite/tests/ui/search/test_backend_search.py b/testsuite/tests/ui/search/test_backend_search.py index 828f28260..233a9a2a0 100644 --- a/testsuite/tests/ui/search/test_backend_search.py +++ b/testsuite/tests/ui/search/test_backend_search.py @@ -3,13 +3,16 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version +from testsuite import TESTED_VERSION from testsuite.ui.views.admin.backend import BackendsView from testsuite.utils import blame -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import -pytestmark = [pytest.mark.usefixtures("login"), pytest.mark.skipif("TESTED_VERSION < Version('2.14-dev')")] +pytestmark = [ + pytest.mark.usefixtures("login"), + pytest.mark.skipif(TESTED_VERSION < Version("2.14-dev"), reason="TESTED_VERSION < Version('2.14-dev')"), +] @pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-8562") diff --git a/testsuite/tests/ui/search/test_product_search.py b/testsuite/tests/ui/search/test_product_search.py index 367a269f3..509a6bdf2 100644 --- a/testsuite/tests/ui/search/test_product_search.py +++ b/testsuite/tests/ui/search/test_product_search.py @@ -3,13 +3,16 @@ """ import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version +from testsuite import TESTED_VERSION from testsuite.ui.views.admin.product import ProductsView from testsuite.utils import blame -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import -pytestmark = [pytest.mark.usefixtures("login"), pytest.mark.skipif("TESTED_VERSION < Version('2.14-dev')")] +pytestmark = [ + pytest.mark.usefixtures("login"), + pytest.mark.skipif(TESTED_VERSION < Version("2.14-dev"), reason="TESTED_VERSION < Version('2.14-dev')"), +] @pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-8562") diff --git a/testsuite/tests/ui/security/test_xss_vulnerability.py b/testsuite/tests/ui/security/test_xss_vulnerability.py index 884215cfd..a3f8cbffc 100644 --- a/testsuite/tests/ui/security/test_xss_vulnerability.py +++ b/testsuite/tests/ui/security/test_xss_vulnerability.py @@ -1,16 +1,16 @@ """Tests aimed to test XSS vulnerabilities""" import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.ui.views.admin.audience.messages import SupportEmailsView from testsuite.ui.views.admin.backend.backend import BackendDetailView from testsuite.utils import blame pytestmark = [ pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6785"), - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.usefixtures("login"), ] diff --git a/testsuite/tests/ui/test_fields_definitions.py b/testsuite/tests/ui/test_fields_definitions.py index bc38b674f..84c61d6ea 100644 --- a/testsuite/tests/ui/test_fields_definitions.py +++ b/testsuite/tests/ui/test_fields_definitions.py @@ -3,8 +3,13 @@ import pytest from widgetastic.widget import TextInput -from testsuite.ui.views.admin.audience.account_user import AccountUserEditView, AccountUserDetailView -from testsuite.ui.views.admin.audience.fields_definitions import FieldsDefinitionsCreateView +from testsuite.ui.views.admin.audience.account_user import ( + AccountUserDetailView, + AccountUserEditView, +) +from testsuite.ui.views.admin.audience.fields_definitions import ( + FieldsDefinitionsCreateView, +) @pytest.fixture(autouse=True) diff --git a/testsuite/tests/ui/test_login_page.py b/testsuite/tests/ui/test_login_page.py index 63d4032dc..c6e7095d7 100644 --- a/testsuite/tests/ui/test_login_page.py +++ b/testsuite/tests/ui/test_login_page.py @@ -62,4 +62,4 @@ def test_log_with_random_username_password(refreshed_browser): login_view.login_widget.fill_passwd("password") assert login_view.login_widget.submit.is_enabled login_view.login_widget.submit.click() - assert "Incorrect email or password. Please try again." in login_view.error_message.text + assert "Incorrect email or password. Please try again." in login_view.error_message.title diff --git a/testsuite/tests/ui/test_logo_upload.py b/testsuite/tests/ui/test_logo_upload.py index 03250dd62..28671d446 100644 --- a/testsuite/tests/ui/test_logo_upload.py +++ b/testsuite/tests/ui/test_logo_upload.py @@ -1,7 +1,7 @@ """Tests developer portal logo upload""" -import pytest import importlib_resources as resources +import pytest from testsuite.ui.views.admin.audience.developer_portal import DeveloperPortalLogoView from testsuite.utils import warn_and_skip diff --git a/testsuite/tests/ui/test_wizard.py b/testsuite/tests/ui/test_wizard.py index 9d2acad3b..20c64cbe4 100644 --- a/testsuite/tests/ui/test_wizard.py +++ b/testsuite/tests/ui/test_wizard.py @@ -7,12 +7,12 @@ import pytest from testsuite.ui.views.admin.wizard import ( - WizardIntroView, WizardBackendApiView, - WizardRequestView, WizardEditApiView, - WizardResponseView, + WizardIntroView, WizardOutroView, + WizardRequestView, + WizardResponseView, ) from testsuite.utils import blame diff --git a/testsuite/tests/ui/users_and_roles/test_no_access_message.py b/testsuite/tests/ui/users_and_roles/test_no_access_message.py index 385338284..8a7f04d02 100644 --- a/testsuite/tests/ui/users_and_roles/test_no_access_message.py +++ b/testsuite/tests/ui/users_and_roles/test_no_access_message.py @@ -1,15 +1,15 @@ """Test for no access message in Dashboard""" import pytest -from packaging.version import Version # noqa # pylint: disable=unused-import +from packaging.version import Version from selenium.webdriver.common.by import By -from testsuite import TESTED_VERSION # noqa # pylint: disable=unused-import +from testsuite import TESTED_VERSION from testsuite.ui.views.admin.audience.support_emails import SupportEmailsView from testsuite.ui.views.admin.foundation import DashboardView pytestmark = [ - pytest.mark.skipif("TESTED_VERSION < Version('2.11')"), + pytest.mark.skipif(TESTED_VERSION < Version("2.11"), reason="TESTED_VERSION < Version('2.11')"), pytest.mark.issue("https://issues.redhat.com/browse/THREESCALE-6321"), ] diff --git a/testsuite/tests/ui/users_and_roles/test_permissions.py b/testsuite/tests/ui/users_and_roles/test_permissions.py index a155804f3..61ed729b1 100644 --- a/testsuite/tests/ui/users_and_roles/test_permissions.py +++ b/testsuite/tests/ui/users_and_roles/test_permissions.py @@ -2,12 +2,12 @@ import pytest -from testsuite.ui.views.admin.audience.billing import BillingView, BillingSettingsView +from testsuite.ui.views.admin.audience.billing import BillingSettingsView, BillingView from testsuite.ui.views.admin.audience.developer_portal import ( - DeveloperPortalContentView, + ActiveDocsView, CMSNewPageView, CMSNewSectionView, - ActiveDocsView, + DeveloperPortalContentView, ) from testsuite.ui.views.admin.foundation import AccessDeniedView diff --git a/testsuite/tests/ui/webhooks/test_webhooks_account.py b/testsuite/tests/ui/webhooks/test_webhooks_account.py index e8e74a69d..5a7922c75 100644 --- a/testsuite/tests/ui/webhooks/test_webhooks_account.py +++ b/testsuite/tests/ui/webhooks/test_webhooks_account.py @@ -7,8 +7,15 @@ import pytest from testsuite import rawobj, resilient -from testsuite.ui.views.admin.audience.account import UsageRulesView, AccountEditView, AccountsDetailView -from testsuite.ui.views.admin.audience.account_plan import NewAccountPlanView, AccountPlansView +from testsuite.ui.views.admin.audience.account import ( + AccountEditView, + AccountsDetailView, + UsageRulesView, +) +from testsuite.ui.views.admin.audience.account_plan import ( + AccountPlansView, + NewAccountPlanView, +) from testsuite.ui.views.admin.settings.webhooks import WebhooksView from testsuite.utils import blame diff --git a/testsuite/tests/ui/webhooks/test_webhooks_application.py b/testsuite/tests/ui/webhooks/test_webhooks_application.py index 292b194a4..866dcc2de 100644 --- a/testsuite/tests/ui/webhooks/test_webhooks_application.py +++ b/testsuite/tests/ui/webhooks/test_webhooks_application.py @@ -7,7 +7,10 @@ import pytest from testsuite import rawobj, resilient -from testsuite.ui.views.admin.audience.application import ApplicationEditView, ApplicationDetailView +from testsuite.ui.views.admin.audience.application import ( + ApplicationDetailView, + ApplicationEditView, +) from testsuite.ui.views.admin.settings.webhooks import WebhooksView from testsuite.utils import blame diff --git a/testsuite/toolbox/toolbox.py b/testsuite/toolbox/toolbox.py index 5613fd5dc..42d995dd6 100644 --- a/testsuite/toolbox/toolbox.py +++ b/testsuite/toolbox/toolbox.py @@ -7,8 +7,9 @@ import jsondiff import paramiko -from testsuite.toolbox import constants + from testsuite.config import settings +from testsuite.toolbox import constants def get_toolbox_cmd(cmd_in): diff --git a/testsuite/tools.py b/testsuite/tools.py index 7a1c67c56..68a5aa6fc 100644 --- a/testsuite/tools.py +++ b/testsuite/tools.py @@ -27,6 +27,7 @@ import inspect import sys + from testsuite.config import settings from testsuite.configuration import openshift from testsuite.openshift.client import OpenShiftClient diff --git a/testsuite/ui/browser.py b/testsuite/ui/browser.py index c6681b91a..7939f7faf 100644 --- a/testsuite/ui/browser.py +++ b/testsuite/ui/browser.py @@ -3,8 +3,8 @@ from contextlib import contextmanager from time import sleep from urllib import parse -import backoff +import backoff from selenium.common.exceptions import NoSuchElementException from widgetastic.browser import Browser, DefaultPlugin diff --git a/testsuite/ui/navigation/__init__.py b/testsuite/ui/navigation/__init__.py index 20187e781..0597b8ea1 100644 --- a/testsuite/ui/navigation/__init__.py +++ b/testsuite/ui/navigation/__init__.py @@ -16,7 +16,7 @@ import inspect from collections import deque -from typing import TypeVar, Type, Optional +from typing import Optional, Type, TypeVar from widgetastic.widget import View diff --git a/testsuite/ui/views/admin/audience/account.py b/testsuite/ui/views/admin/audience/account.py index e32fd271f..71de211e5 100644 --- a/testsuite/ui/views/admin/audience/account.py +++ b/testsuite/ui/views/admin/audience/account.py @@ -1,22 +1,22 @@ """View representations of Accounts pages""" -from widgetastic.widget import TextInput, GenericLocatorWidget, Text, View +from widgetastic.widget import GenericLocatorWidget, Text, TextInput, View from widgetastic_patternfly4 import PatternflyTable from testsuite.ui.navigation import step from testsuite.ui.views.admin.audience import BaseAudienceView from testsuite.ui.views.common.foundation import FlashMessage from testsuite.ui.widgets import ( - ThreescaleDropdown, - ThreescaleCheckBox, CheckBoxGroup, HorizontalNavigation, + ThreescaleCheckBox, + ThreescaleDropdown, ) from testsuite.ui.widgets.buttons import ( - ThreescaleUpdateButton, ThreescaleDeleteButton, ThreescaleEditButton, ThreescaleSubmitButton, + ThreescaleUpdateButton, ) from testsuite.ui.widgets.searchinput import ThreescaleSearchInput diff --git a/testsuite/ui/views/admin/audience/account_plan.py b/testsuite/ui/views/admin/audience/account_plan.py index a1dd9b627..ed20054d3 100644 --- a/testsuite/ui/views/admin/audience/account_plan.py +++ b/testsuite/ui/views/admin/audience/account_plan.py @@ -1,7 +1,7 @@ """View representations of Account plan pages""" -from widgetastic.widget import TextInput, GenericLocatorWidget, Text -from widgetastic_patternfly4 import PatternflyTable, Dropdown +from widgetastic.widget import GenericLocatorWidget, Text, TextInput +from widgetastic_patternfly4 import Dropdown, PatternflyTable from testsuite.ui.navigation import step from testsuite.ui.views.admin.audience import BaseAudienceView diff --git a/testsuite/ui/views/admin/audience/account_user.py b/testsuite/ui/views/admin/audience/account_user.py index f27974217..27bb5dc5a 100644 --- a/testsuite/ui/views/admin/audience/account_user.py +++ b/testsuite/ui/views/admin/audience/account_user.py @@ -1,6 +1,6 @@ """View representations of Account User pages""" -from widgetastic.widget import TextInput, Text +from widgetastic.widget import Text, TextInput from widgetastic_patternfly4 import PatternflyTable from testsuite.ui.navigation import step diff --git a/testsuite/ui/views/admin/audience/application.py b/testsuite/ui/views/admin/audience/application.py index d29219bd9..38edeb9ab 100644 --- a/testsuite/ui/views/admin/audience/application.py +++ b/testsuite/ui/views/admin/audience/application.py @@ -2,7 +2,7 @@ from time import sleep -from widgetastic.widget import View, TextInput, Text, GenericLocatorWidget +from widgetastic.widget import GenericLocatorWidget, Text, TextInput, View from widgetastic_patternfly4 import PatternflyTable from widgetastic_patternfly4.ouia import Select @@ -12,11 +12,11 @@ from testsuite.ui.views.admin.product import BaseProductView from testsuite.ui.widgets import ThreescaleCheckBox from testsuite.ui.widgets.buttons import ( - ThreescaleUpdateButton, - ThreescaleDeleteButton, ThreescaleCreateButton, + ThreescaleDeleteButton, ThreescaleEditButton, ThreescaleSubmitButton, + ThreescaleUpdateButton, ) diff --git a/testsuite/ui/views/admin/audience/billing.py b/testsuite/ui/views/admin/audience/billing.py index f0a28da8c..91c75935f 100644 --- a/testsuite/ui/views/admin/audience/billing.py +++ b/testsuite/ui/views/admin/audience/billing.py @@ -1,6 +1,6 @@ """View representations of Billing pages""" -from widgetastic.widget import Select, ConditionalSwitchableView, View, TextInput, Text +from widgetastic.widget import ConditionalSwitchableView, Select, Text, TextInput, View from widgetastic_patternfly4 import PatternflyTable from testsuite.ui.views.admin.audience import BaseAudienceView diff --git a/testsuite/ui/views/admin/audience/developer_portal/__init__.py b/testsuite/ui/views/admin/audience/developer_portal/__init__.py index 0ffbcc091..883379aa4 100644 --- a/testsuite/ui/views/admin/audience/developer_portal/__init__.py +++ b/testsuite/ui/views/admin/audience/developer_portal/__init__.py @@ -2,20 +2,24 @@ from selenium.common.exceptions import NoSuchElementException from wait_for import TimedOutError, wait_for -from widgetastic.widget import GenericLocatorWidget, TextInput, Text, FileInput, Image +from widgetastic.widget import FileInput, GenericLocatorWidget, Image, Text, TextInput from widgetastic_patternfly4 import PatternflyTable from testsuite.ui.navigation import step from testsuite.ui.views.admin.audience import BaseAudienceView from testsuite.ui.widgets import ( - ThreescaleDropdown, + APIDocsSelect, + CheckBoxGroup, DivBasedEditor, ThreescaleButtonGroup, ThreescaleCheckBox, - CheckBoxGroup, - APIDocsSelect, + ThreescaleDropdown, +) +from testsuite.ui.widgets.buttons import ( + ThreescaleCreateButton, + ThreescaleDeleteButton, + ThreescaleSubmitButton, ) -from testsuite.ui.widgets.buttons import ThreescaleSubmitButton, ThreescaleDeleteButton, ThreescaleCreateButton class CMSNewPageView(BaseAudienceView): diff --git a/testsuite/ui/views/admin/audience/developer_portal/sso_integrations.py b/testsuite/ui/views/admin/audience/developer_portal/sso_integrations.py index 4e51a9e87..15ac09baf 100644 --- a/testsuite/ui/views/admin/audience/developer_portal/sso_integrations.py +++ b/testsuite/ui/views/admin/audience/developer_portal/sso_integrations.py @@ -1,6 +1,6 @@ """View representations of SSO Integrations pages for developer portal""" -from widgetastic.widget import TextInput, Text +from widgetastic.widget import Text, TextInput from widgetastic_patternfly4 import PatternflyTable from testsuite.ui.navigation import step diff --git a/testsuite/ui/views/admin/audience/messages.py b/testsuite/ui/views/admin/audience/messages.py index 32088790f..a2b25322b 100644 --- a/testsuite/ui/views/admin/audience/messages.py +++ b/testsuite/ui/views/admin/audience/messages.py @@ -2,10 +2,9 @@ import re -from widgetastic.widget import GenericLocatorWidget, View, Text +from widgetastic.widget import GenericLocatorWidget, Text, View from widgetastic_patternfly import TextInput - -from widgetastic_patternfly4 import Button, PatternflyTable, Dropdown +from widgetastic_patternfly4 import Button, Dropdown, PatternflyTable from widgetastic_patternfly4.ouia import Dropdown as OUIADropdown from testsuite.ui.navigation import step diff --git a/testsuite/ui/views/admin/backend/__init__.py b/testsuite/ui/views/admin/backend/__init__.py index 179800b19..69b29c5e6 100644 --- a/testsuite/ui/views/admin/backend/__init__.py +++ b/testsuite/ui/views/admin/backend/__init__.py @@ -1,7 +1,7 @@ """Essential Views for Backends Views""" -from widgetastic_patternfly4 import PatternflyTable from widgetastic.widget import Text +from widgetastic_patternfly4 import PatternflyTable from testsuite.ui.navigation import step from testsuite.ui.views.admin.foundation import BaseAdminView diff --git a/testsuite/ui/views/admin/backend/backend.py b/testsuite/ui/views/admin/backend/backend.py index 81ac0a8c9..c156ad090 100644 --- a/testsuite/ui/views/admin/backend/backend.py +++ b/testsuite/ui/views/admin/backend/backend.py @@ -1,12 +1,15 @@ """View representations of Backend pages""" -from widgetastic.widget import TextInput -from widgetastic.widget import Text +from widgetastic.widget import Text, TextInput from testsuite.ui.navigation import step from testsuite.ui.views.admin.backend import BackendsView, BaseBackendView from testsuite.ui.views.admin.foundation import BaseAdminView -from testsuite.ui.widgets.buttons import ThreescaleUpdateButton, ThreescaleDeleteButton, ThreescaleSubmitButton +from testsuite.ui.widgets.buttons import ( + ThreescaleDeleteButton, + ThreescaleSubmitButton, + ThreescaleUpdateButton, +) class BackendNewView(BaseAdminView): diff --git a/testsuite/ui/views/admin/foundation.py b/testsuite/ui/views/admin/foundation.py index cbd4a1ba7..94fadc3fd 100644 --- a/testsuite/ui/views/admin/foundation.py +++ b/testsuite/ui/views/admin/foundation.py @@ -4,11 +4,11 @@ Admin portal pages. """ -from widgetastic.widget import GenericLocatorWidget, View, Text +from widgetastic.widget import GenericLocatorWidget, Text, View from widgetastic_patternfly4 import Button from widgetastic_patternfly4.ouia import Dropdown -from testsuite.ui.navigation import step, Navigable +from testsuite.ui.navigation import Navigable, step class BaseAdminView(View, Navigable): diff --git a/testsuite/ui/views/admin/login.py b/testsuite/ui/views/admin/login.py index e9d7337df..9974fa23e 100644 --- a/testsuite/ui/views/admin/login.py +++ b/testsuite/ui/views/admin/login.py @@ -1,7 +1,7 @@ """Representation of Login specific views""" -from widgetastic.widget import View, Text, TextInput, GenericLocatorWidget -from widgetastic_patternfly4.ouia import Button +from widgetastic.widget import GenericLocatorWidget, Text, TextInput, View +from widgetastic_patternfly4.ouia import Alert, Button from testsuite.ui.exception import UIException from testsuite.ui.navigation import Navigable, step @@ -10,6 +10,17 @@ from testsuite.ui.views.common.login import LoginForm +class AdminReCaptcha(View): + """ReCaptcha badge for admin portal — searches from browser root to escape view ROOT scoping.""" + + @property + def is_displayed(self): + element = self.browser.wait_for_element( + "//div[contains(@class,'grecaptcha-logo')]", timeout=10, exception=False + ) + return element is not None + + class LoginView(View, Navigable): """ Basic login view page object that can be found on path @@ -18,9 +29,10 @@ class LoginView(View, Navigable): path = "/p/login" ROOT = "/html//div[@id='pf-login-page-container']" header = Text("//main/header/h2") - error_message = Text("//h4[@class='pf-c-alert__title']") + error_message = Alert(component_id="OUIA-Generated-Alert-danger-1") login_widget = View.nested(LoginForm) password_reset_link = Text("//a[@href='/p/password/reset']") + recaptcha = View.nested(AdminReCaptcha) auth0_link = Text("//*[@class='login-provider-link' and contains(@href,'auth0')]") rhsso_link = Text("//*[@class='login-provider-link' and contains(@href,'keycloak')]") @@ -91,6 +103,8 @@ class RequestAdminPasswordView(View, Navigable): path = "/p/password/reset" password_reset_field = TextInput(id="email") passwd_reset_btn = Button(component_id="OUIA-Generated-Button-primary-1") + recaptcha = View.nested(AdminReCaptcha) + error_message = Alert(component_id="OUIA-Generated-Alert-danger-1") def reset_password(self, email): """Reset password of email address user""" diff --git a/testsuite/ui/views/admin/product/active_docs.py b/testsuite/ui/views/admin/product/active_docs.py index ee2b48c8d..bcf85e78c 100644 --- a/testsuite/ui/views/admin/product/active_docs.py +++ b/testsuite/ui/views/admin/product/active_docs.py @@ -1,12 +1,12 @@ """View representations of Product Active docs pages""" +from widgetastic.widget import Text, View from widgetastic_patternfly4 import PatternflyTable -from widgetastic.widget import View, Text +from testsuite.ui.navigation import step from testsuite.ui.views.admin.product import BaseProductView -from testsuite.ui.widgets.buttons import ThreescaleDeleteButton, ThreescaleEditButton from testsuite.ui.widgets import ActiveDocV2Section, ThreescaleDeleteEditGroup2 -from testsuite.ui.navigation import step +from testsuite.ui.widgets.buttons import ThreescaleDeleteButton, ThreescaleEditButton from testsuite.ui.widgets.oas3 import Endpoint diff --git a/testsuite/ui/views/admin/product/application.py b/testsuite/ui/views/admin/product/application.py index 0dc3487c2..0ac4f1654 100644 --- a/testsuite/ui/views/admin/product/application.py +++ b/testsuite/ui/views/admin/product/application.py @@ -5,9 +5,13 @@ from testsuite.ui.navigation import step from testsuite.ui.views.admin.product import BaseProductView -from testsuite.ui.widgets import GenericLocatorWidget -from testsuite.ui.widgets.buttons import ThreescaleUpdateButton, ThreescaleCreateButton, ThreescaleSubmitButton from testsuite.ui.views.common.foundation import FlashMessage +from testsuite.ui.widgets import GenericLocatorWidget +from testsuite.ui.widgets.buttons import ( + ThreescaleCreateButton, + ThreescaleSubmitButton, + ThreescaleUpdateButton, +) class ApplicationPlansView(BaseProductView): diff --git a/testsuite/ui/views/admin/product/integration/backends.py b/testsuite/ui/views/admin/product/integration/backends.py index 15473f85a..667397575 100644 --- a/testsuite/ui/views/admin/product/integration/backends.py +++ b/testsuite/ui/views/admin/product/integration/backends.py @@ -1,7 +1,7 @@ """View representations of products integration backends section pages""" -from widgetastic.widget import TextInput, Text -from widgetastic_patternfly4 import PatternflyTable, Button +from widgetastic.widget import Text, TextInput +from widgetastic_patternfly4 import Button, PatternflyTable from widgetastic_patternfly4.ouia import Select from testsuite.ui.navigation import step diff --git a/testsuite/ui/views/admin/product/integration/configuration.py b/testsuite/ui/views/admin/product/integration/configuration.py index 1c85a0dcb..ea196a20d 100644 --- a/testsuite/ui/views/admin/product/integration/configuration.py +++ b/testsuite/ui/views/admin/product/integration/configuration.py @@ -1,6 +1,6 @@ """View representations of products integration configuration section pages""" -from widgetastic.widget import View, ParametrizedLocator +from widgetastic.widget import ParametrizedLocator, View from widgetastic_patternfly4 import Button from testsuite.ui.views.admin.product import BaseProductView diff --git a/testsuite/ui/views/admin/product/integration/methods_and_metrics.py b/testsuite/ui/views/admin/product/integration/methods_and_metrics.py index 1e8400aa0..3a22fa141 100644 --- a/testsuite/ui/views/admin/product/integration/methods_and_metrics.py +++ b/testsuite/ui/views/admin/product/integration/methods_and_metrics.py @@ -1,6 +1,6 @@ """View representations of product's methods and metrics pages""" -from widgetastic.widget import TextInput, Table, Text, GenericLocatorWidget, View +from widgetastic.widget import GenericLocatorWidget, Table, Text, TextInput, View from widgetastic_patternfly4 import Button from testsuite.ui.navigation import step diff --git a/testsuite/ui/views/admin/product/integration/policies.py b/testsuite/ui/views/admin/product/integration/policies.py index 604942d7c..463bb2cee 100644 --- a/testsuite/ui/views/admin/product/integration/policies.py +++ b/testsuite/ui/views/admin/product/integration/policies.py @@ -3,7 +3,7 @@ import enum from typing import Literal -from widgetastic.widget import TextInput, View, FileInput +from widgetastic.widget import FileInput, TextInput, View from widgetastic_patternfly4 import Button from testsuite.certificates import Certificate diff --git a/testsuite/ui/views/admin/product/product.py b/testsuite/ui/views/admin/product/product.py index dd3ab9234..7038ec908 100644 --- a/testsuite/ui/views/admin/product/product.py +++ b/testsuite/ui/views/admin/product/product.py @@ -1,13 +1,22 @@ """View representations of Product pages""" -from widgetastic.widget import TextInput, ConditionalSwitchableView, GenericLocatorWidget, View +from widgetastic.widget import ( + ConditionalSwitchableView, + GenericLocatorWidget, + TextInput, + View, +) from widgetastic_patternfly4 import Button from testsuite.ui.navigation import step from testsuite.ui.views.admin.foundation import BaseAdminView from testsuite.ui.views.admin.product import BaseProductView, ProductsView from testsuite.ui.widgets import RadioGroup, ThreescaleDropdown -from testsuite.ui.widgets.buttons import ThreescaleCreateButton, ThreescaleUpdateButton, ThreescaleDeleteButton +from testsuite.ui.widgets.buttons import ( + ThreescaleCreateButton, + ThreescaleDeleteButton, + ThreescaleUpdateButton, +) class ProductNewView(BaseAdminView): diff --git a/testsuite/ui/views/admin/settings/bot_protection.py b/testsuite/ui/views/admin/settings/bot_protection.py new file mode 100644 index 000000000..71249b4c2 --- /dev/null +++ b/testsuite/ui/views/admin/settings/bot_protection.py @@ -0,0 +1,37 @@ +"""View representation of Admin Portal Bot Protection settings page""" + +from widgetastic.widget import Text + +from testsuite.ui.views.admin.settings import BaseSettingsView +from testsuite.ui.widgets.buttons import ThreescaleSubmitButton + + +class AdminBotProtection(BaseSettingsView): + """View representation of Admin Portal Bot Protection settings""" + + path_pattern = "/p/admin/bot_protection/edit" + no_protection = Text('//*[@id="settings_admin_bot_protection_level_none"]') + recaptcha_protection = Text('//*[@id="settings_admin_bot_protection_level_captcha"]') + submit_button = ThreescaleSubmitButton() + + def prerequisite(self): + return BaseSettingsView + + def disable_protection(self): + """Disables admin portal bot protection by selecting None and submitting.""" + self.no_protection.click() + self.submit_button.click() + + def enable_protection(self): + """Enables admin portal bot protection by selecting reCAPTCHA v3 and submitting.""" + self.recaptcha_protection.click() + self.submit_button.click() + + @property + def is_displayed(self): + return ( + BaseSettingsView.is_displayed.fget(self) + and self.path in self.browser.url + and self.no_protection.is_displayed + and self.recaptcha_protection.is_displayed + ) diff --git a/testsuite/ui/views/admin/settings/sso_integrations.py b/testsuite/ui/views/admin/settings/sso_integrations.py index 58fa24e58..6da9a2ffa 100644 --- a/testsuite/ui/views/admin/settings/sso_integrations.py +++ b/testsuite/ui/views/admin/settings/sso_integrations.py @@ -2,13 +2,17 @@ from urllib.parse import urlparse -from widgetastic.widget import TextInput, Text -from widgetastic_patternfly4 import PatternflyTable, Button +from widgetastic.widget import Text, TextInput +from widgetastic_patternfly4 import Button, PatternflyTable from testsuite.ui.navigation import step from testsuite.ui.views.admin.settings import BaseSettingsView -from testsuite.ui.widgets import ThreescaleDropdown, ThreescaleCheckBox -from testsuite.ui.widgets.buttons import ThreescaleCreateButton, ThreescaleEditButton, ThreescaleDeleteButton +from testsuite.ui.widgets import ThreescaleCheckBox, ThreescaleDropdown +from testsuite.ui.widgets.buttons import ( + ThreescaleCreateButton, + ThreescaleDeleteButton, + ThreescaleEditButton, +) class SSOIntegrationsView(BaseSettingsView): diff --git a/testsuite/ui/views/admin/settings/tokens.py b/testsuite/ui/views/admin/settings/tokens.py index 283e4e4f4..6c39a8c06 100644 --- a/testsuite/ui/views/admin/settings/tokens.py +++ b/testsuite/ui/views/admin/settings/tokens.py @@ -3,12 +3,12 @@ import enum from typing import List -from widgetastic.widget import TextInput, Text +from widgetastic.widget import Text, TextInput from widgetastic_patternfly4 import PatternflyTable from testsuite.ui.navigation import step from testsuite.ui.views.admin.settings import BaseSettingsView -from testsuite.ui.widgets import ThreescaleDropdown, PfCheckBoxGroup +from testsuite.ui.widgets import PfCheckBoxGroup, ThreescaleDropdown from testsuite.ui.widgets.buttons import ThreescaleSubmitButton diff --git a/testsuite/ui/views/admin/settings/webhooks.py b/testsuite/ui/views/admin/settings/webhooks.py index fe72bd60c..206bf693e 100644 --- a/testsuite/ui/views/admin/settings/webhooks.py +++ b/testsuite/ui/views/admin/settings/webhooks.py @@ -2,8 +2,7 @@ View representations of Webhook pages """ -from widgetastic.widget import TextInput, GenericLocatorWidget - +from widgetastic.widget import GenericLocatorWidget, TextInput from testsuite.ui.views.admin.settings import BaseSettingsView from testsuite.ui.widgets import PfCheckBoxGroup diff --git a/testsuite/ui/views/admin/wizard.py b/testsuite/ui/views/admin/wizard.py index b48f17f68..1986a347e 100644 --- a/testsuite/ui/views/admin/wizard.py +++ b/testsuite/ui/views/admin/wizard.py @@ -1,10 +1,10 @@ """Introduction wizard pages module""" -from widgetastic.widget import View, GenericLocatorWidget, TextInput +from widgetastic.widget import GenericLocatorWidget, TextInput, View from widgetastic_patternfly import Text from widgetastic_patternfly4 import Button -from testsuite.ui.navigation import step, Navigable +from testsuite.ui.navigation import Navigable, step from testsuite.ui.widgets.buttons import ThreescaleSubmitButton diff --git a/testsuite/ui/views/auth.py b/testsuite/ui/views/auth.py index f70031086..77b757327 100644 --- a/testsuite/ui/views/auth.py +++ b/testsuite/ui/views/auth.py @@ -1,7 +1,7 @@ """View representations of 3rd party auth pages""" from weakget import weakget -from widgetastic.widget import View, TextInput, GenericLocatorWidget, Text +from widgetastic.widget import GenericLocatorWidget, Text, TextInput, View from testsuite import settings from testsuite.ui.navigation import Navigable diff --git a/testsuite/ui/views/common/foundation.py b/testsuite/ui/views/common/foundation.py index 4ca20f27c..90aa4986f 100644 --- a/testsuite/ui/views/common/foundation.py +++ b/testsuite/ui/views/common/foundation.py @@ -2,7 +2,7 @@ Module contains Base View used for all Views that are the same in Admin and Master. """ -from widgetastic.widget import GenericLocatorWidget, View, Text +from widgetastic.widget import GenericLocatorWidget, Text, View class FlashMessage(View): diff --git a/testsuite/ui/views/common/login.py b/testsuite/ui/views/common/login.py index 4453d0210..a037f6abf 100644 --- a/testsuite/ui/views/common/login.py +++ b/testsuite/ui/views/common/login.py @@ -1,6 +1,6 @@ """Login portion which is the same for admin and master""" -from widgetastic.widget import TextInput, View, Text +from widgetastic.widget import Text, TextInput, View from testsuite.ui.widgets.buttons import ThreescaleSubmitButton diff --git a/testsuite/ui/views/devel/__init__.py b/testsuite/ui/views/devel/__init__.py index b1e24c3a9..852ee67ce 100644 --- a/testsuite/ui/views/devel/__init__.py +++ b/testsuite/ui/views/devel/__init__.py @@ -1,6 +1,6 @@ """Contains basic views for Developer portal""" -from widgetastic.widget import View, Text, TextInput, GenericLocatorWidget +from widgetastic.widget import GenericLocatorWidget, Text, TextInput, View from testsuite.ui.navigation import Navigable, step from testsuite.ui.widgets.oas3 import Endpoint diff --git a/testsuite/ui/views/devel/applications.py b/testsuite/ui/views/devel/applications.py index 4c97bdde1..f3477daa0 100644 --- a/testsuite/ui/views/devel/applications.py +++ b/testsuite/ui/views/devel/applications.py @@ -1,6 +1,6 @@ """Devel applications pages and tabs""" -from widgetastic.widget import Text, Table +from widgetastic.widget import Table, Text from testsuite.ui.navigation import step from testsuite.ui.views.devel import BaseDevelView, Navbar diff --git a/testsuite/ui/views/devel/login.py b/testsuite/ui/views/devel/login.py index 6624de60b..702deea6a 100644 --- a/testsuite/ui/views/devel/login.py +++ b/testsuite/ui/views/devel/login.py @@ -1,14 +1,14 @@ """Representation of login specific Views""" -from widgetastic.widget import TextInput, Text, View, GenericLocatorWidget +from widgetastic.widget import GenericLocatorWidget, Text, TextInput, View from testsuite.ui.exception import UIException from testsuite.ui.navigation import step +from testsuite.ui.views.auth import Auth0View, RhssoView from testsuite.ui.views.common.foundation import FlashMessage -from testsuite.ui.widgets.buttons import ThreescaleSubmitButton -from testsuite.ui.views.auth import RhssoView, Auth0View -from testsuite.ui.views.devel import BaseDevelView, SignUpView from testsuite.ui.views.common.login import LoginForm +from testsuite.ui.views.devel import BaseDevelView, SignUpView +from testsuite.ui.widgets.buttons import ThreescaleSubmitButton class ReCaptcha(View): diff --git a/testsuite/ui/views/devel/messages.py b/testsuite/ui/views/devel/messages.py index a981a2bc5..36864f9a9 100644 --- a/testsuite/ui/views/devel/messages.py +++ b/testsuite/ui/views/devel/messages.py @@ -1,6 +1,6 @@ """Devel messages pages and tabs""" -from widgetastic.widget import TextInput, View, Text +from widgetastic.widget import Text, TextInput, View from widgetastic_patternfly4 import PatternflyTable from testsuite.ui.navigation import Navigable, step diff --git a/testsuite/ui/views/devel/settings/__init__.py b/testsuite/ui/views/devel/settings/__init__.py index 66b8ddce2..e804e53da 100644 --- a/testsuite/ui/views/devel/settings/__init__.py +++ b/testsuite/ui/views/devel/settings/__init__.py @@ -1,8 +1,8 @@ """Devel account settings""" -from widgetastic.widget import View, Text +from widgetastic.widget import Text, View -from testsuite.ui.navigation import step, Navigable +from testsuite.ui.navigation import Navigable, step from testsuite.ui.views.devel import BaseDevelView, Navbar diff --git a/testsuite/ui/views/devel/settings/braintree.py b/testsuite/ui/views/devel/settings/braintree.py index e5e04a377..1b44d1d1f 100644 --- a/testsuite/ui/views/devel/settings/braintree.py +++ b/testsuite/ui/views/devel/settings/braintree.py @@ -5,7 +5,7 @@ from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.wait import WebDriverWait from wait_for import TimedOutError -from widgetastic.widget import View, TextInput, Select, GenericLocatorWidget, Text +from widgetastic.widget import GenericLocatorWidget, Select, Text, TextInput, View from widgetastic_patternfly import Button from testsuite.ui.objects import BillingAddress, CreditCard diff --git a/testsuite/ui/views/devel/settings/stripe.py b/testsuite/ui/views/devel/settings/stripe.py index 32222959f..7ad082e0a 100644 --- a/testsuite/ui/views/devel/settings/stripe.py +++ b/testsuite/ui/views/devel/settings/stripe.py @@ -3,9 +3,9 @@ import logging import time -from widgetastic.widget import View, TextInput, Select, GenericLocatorWidget, Text +from widgetastic.widget import GenericLocatorWidget, Select, Text, TextInput, View -from testsuite.ui.objects import CreditCard, BillingAddress +from testsuite.ui.objects import BillingAddress, CreditCard from testsuite.ui.views.devel import BaseDevelView from testsuite.ui.views.devel.settings import SettingsTabs from testsuite.ui.widgets.buttons import ThreescaleSubmitButton diff --git a/testsuite/ui/views/master/audience/tenant.py b/testsuite/ui/views/master/audience/tenant.py index f6b4cbebd..4756a77b8 100644 --- a/testsuite/ui/views/master/audience/tenant.py +++ b/testsuite/ui/views/master/audience/tenant.py @@ -1,6 +1,6 @@ """View representations of Tenants pages""" -from widgetastic.widget import TextInput, Text +from widgetastic.widget import Text, TextInput from widgetastic_patternfly4 import PatternflyTable from testsuite.ui.navigation import step @@ -9,8 +9,8 @@ Button, ThreescaleDeleteButton, ThreescaleEditButton, - ThreescaleSubmitButton, ThreescaleSearchButton, + ThreescaleSubmitButton, ThreescaleUpdateButton, ) diff --git a/testsuite/ui/views/master/foundation.py b/testsuite/ui/views/master/foundation.py index 1e407e342..a10a42672 100644 --- a/testsuite/ui/views/master/foundation.py +++ b/testsuite/ui/views/master/foundation.py @@ -3,11 +3,11 @@ All of them creates basic page structure for respective Master portal pages. """ -from widgetastic.widget import View, Text, GenericLocatorWidget +from widgetastic.widget import GenericLocatorWidget, Text, View from widgetastic_patternfly4 import Button from widgetastic_patternfly4.ouia import Dropdown -from testsuite.ui.navigation import step, Navigable +from testsuite.ui.navigation import Navigable, step class BaseMasterView(View, Navigable): diff --git a/testsuite/ui/views/master/login.py b/testsuite/ui/views/master/login.py index a0a5d5498..c5a6b28de 100644 --- a/testsuite/ui/views/master/login.py +++ b/testsuite/ui/views/master/login.py @@ -1,6 +1,6 @@ """Representation of Login specific MASTER views""" -from widgetastic.widget import View, Text +from widgetastic.widget import Text, View from testsuite.ui.navigation import Navigable from testsuite.ui.views.admin.login import LoginForm diff --git a/testsuite/ui/widgets/__init__.py b/testsuite/ui/widgets/__init__.py index 753eb7e30..c26ceb92d 100644 --- a/testsuite/ui/widgets/__init__.py +++ b/testsuite/ui/widgets/__init__.py @@ -5,10 +5,9 @@ from selenium.webdriver.common.by import By from widgetastic.exceptions import NoSuchElementException from widgetastic.utils import ParametrizedLocator -from widgetastic.widget import GenericLocatorWidget, Widget, View -from widgetastic.widget import TextInput +from widgetastic.widget import GenericLocatorWidget, TextInput, View, Widget from widgetastic.xpath import quote -from widgetastic_patternfly4 import Select, Modal +from widgetastic_patternfly4 import Modal, Select from testsuite.ui.exception import ItemNotPresentException diff --git a/testsuite/ui/widgets/oas3.py b/testsuite/ui/widgets/oas3.py index 2a57d1371..c9ced9c4a 100644 --- a/testsuite/ui/widgets/oas3.py +++ b/testsuite/ui/widgets/oas3.py @@ -2,11 +2,17 @@ from selenium.webdriver.common.by import By from widgetastic.utils import ParametrizedLocator -from widgetastic.widget import ParametrizedView, Text, Table, Widget, TextInput, GenericLocatorWidget - -# pylint: disable=abstract-method +from widgetastic.widget import ( + GenericLocatorWidget, + ParametrizedView, + Table, + Text, + TextInput, + Widget, +) +# pylint: disable=abstract-method class OAS3DropDown(Widget): """DropDown element used by OAS3. Usually used for key selection or autocomplete function""" diff --git a/testsuite/ui/widgets/ouia.py b/testsuite/ui/widgets/ouia.py index c03546248..d639b5750 100644 --- a/testsuite/ui/widgets/ouia.py +++ b/testsuite/ui/widgets/ouia.py @@ -5,8 +5,8 @@ from selenium.webdriver.common.by import By from widgetastic.types import ViewParent -from widgetastic_patternfly4.navigation import check_nav_loaded from widgetastic_patternfly4 import ouia +from widgetastic_patternfly4.navigation import check_nav_loaded # pylint: disable=abstract-method diff --git a/testsuite/utils.py b/testsuite/utils.py index d4abcce22..0839e70f2 100644 --- a/testsuite/utils.py +++ b/testsuite/utils.py @@ -1,12 +1,12 @@ "testsuite helpers" import os -from datetime import datetime, timezone import secrets import time import typing import warnings from base64 import b64encode +from datetime import datetime, timezone from os import urandom from pathlib import Path