Skip to content

Commit 7bcd481

Browse files
authored
Merge pull request #1036 from mdujava/backports-2.16-20260514
[stable-2.16] backports for 2.16
2 parents 8c93131 + 2d662d5 commit 7bcd481

332 files changed

Lines changed: 1126 additions & 751 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.git-blame-ignore-revs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
b0bf287f7f07c727c498deaa199f2629a3aac5a9 # black 24.1.1 changes
1010
9261b5ae4bf0d53058e6adf2e5d2544011360ba7 # Change regarding flake8 check for python 3.12
1111
d499948418f6e1dc432dabf11f158e58d9a0b0d8 # black 25.1.0 changes
12-
5083c776e66ae613558918342ecf9f0a368f6e99 # isort --profile black
12+
7619a4c61d7914b16088f585e2bceacebf26ec88 # reduce new lines to one after import block
13+
a5deb34f80c6644936cb192686ded29a292d1e8f # unpacking tuple does not need () on lhs
14+
80bb9d6d9f11ac33d6c9287261d2ce44aadd3f87 # fix type ignore comment
15+
1894935618597e2d219e17fa7b1fd0b0fa919515 # isort --profile black

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,17 @@ ifeq ($(filter-out --store --load,$(flags)),$(flags))
4949
endif
5050

5151
commit-acceptance: ## Run all linters, checks, formatters
52-
commit-acceptance: pylint flake8 mypy all-is-package black-check
52+
commit-acceptance: pylint flake8 mypy all-is-package black-check isort-check
5353

5454
pylint flake8 mypy: pipenv-dev
5555
pipenv run $@ $(flags) testsuite
5656

5757
black-check: pipenv-dev
5858
pipenv run black --check testsuite
5959

60+
isort-check: pipenv-dev
61+
pipenv run isort -c --profile black testsuite
62+
6063
all-is-package:
6164
@echo
6265
@echo "Searching for dirs missing __init__.py"

Pipfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ types-braintree = "*"
99
types-stripe = "*"
1010
types-Pillow = "*"
1111
black = "*"
12+
isort = "*"
13+
# this will use system ca-bundle
14+
pip-system-certs = "*"
1215
# Have commented out python-language-server to make it available quickly
1316
# for the development
1417
#python-language-server = "*"
@@ -30,7 +33,7 @@ pytest-asyncio = "==0.21.2"
3033
requests = "*"
3134
dynaconf = "*"
3235
python-keycloak = ">=4.7.3" # this fix needed: https://github.com/marcospereirampj/python-keycloak/pull/622/files
33-
backoff = "*"
36+
python-backoff = "*"
3437
websocket_client = "==1.5.1"
3538
httpx = {version = "*", extras = ["http2"]}
3639
selenium = ">=4.0.0"

scripts/junit2reportportal

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ token = os.environ[args.token_variable]
5959
reportportal = args.reportportal.rstrip("/")
6060

6161
auth = {"Authorization": f"Bearer {token}"}
62-
launch_import = f"{reportportal}/api/v1/{args.project}/launch/import"
62+
launch_import = f"{reportportal}/api/v1/plugin/{args.project}/junit/import"
6363

64-
print(requests.post(launch_import, files={"file": (f"{args.launch_name}.zip", stream.getbuffer(), "application/zip")}, headers=auth).text)
64+
print(requests.post(launch_import, files={"file": (f"{args.launch_name}.zip", stream.getbuffer(), "application/zip"),
65+
"launchImportRq": (None, f'{{"name": "{args.launch_name}"}}', "application/json")},
66+
headers=auth).text)

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
max-line-length = 120
33
ignore = E203,W503
44

5+
[isort]
6+
profile = "black"
7+
58
[mypy]
69
ignore_missing_imports = True

testsuite/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
handler.setFormatter(formatter)
2121
logger.addHandler(handler)
2222

23-
from pathlib import Path # noqa
24-
from packaging.version import Version # noqa
25-
from weakget import weakget
23+
from pathlib import Path
24+
2625
import importlib_resources as resources
26+
from packaging.version import Version
27+
from weakget import weakget
2728

2829
from testsuite.config import settings # noqa
2930

testsuite/billing.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,34 @@
55
import stripe
66
from braintree.exceptions.request_timeout_error import RequestTimeoutError
77
from braintree.exceptions.service_unavailable_error import ServiceUnavailableError
8-
98
from threescale_api.resources import InvoiceState
109

1110

1211
class Stripe:
1312
"""API for Stripe"""
1413

15-
def __init__(self, api_key):
14+
def __init__(self, api_key, provider_account_id):
1615
# Due to fact that we can set up only one Stripe per 3scale and we use same api_key everytime this
1716
# is not disruptive even if it looks like it is.
1817
stripe.api_key = api_key
18+
self.provider_account_id = provider_account_id
1919

2020
@staticmethod
2121
@backoff.on_predicate(backoff.fibo, lambda x: x == [], max_tries=10, jitter=None)
2222
def read_charge(customer):
2323
"""Retrieves the details of the charge"""
24-
return stripe.Charge.search(query=f"customer:'{customer['id']}'").get("data")
24+
return stripe.Charge.search(query=f"customer:'{customer['id']}'").data
2525

26-
@staticmethod
2726
@backoff.on_exception(backoff.expo, IndexError, max_tries=4, jitter=None)
28-
def read_customer_by_account(account):
27+
def read_customer_by_account(self, account):
2928
"""
3029
Read Stripe customer.
3130
Different 3scale deployments can have customers with the same id, which is reflected to the
3231
`3scale_account_reference` Stripe Customer variable. This method reads just the last one.
3332
"""
3433
return stripe.Customer.search(
35-
query=f"metadata['3scale_account_reference']:'3scale-2-{str(account.entity_id)}'"
36-
).get("data")[0]
34+
query=f"metadata['3scale_account_reference']:'3scale-{self.provider_account_id}-{str(account.entity_id)}'"
35+
).data[0]
3736

3837
def assert_payment(self, invoice, account):
3938
"""Compare 3scale and Stripe invoices"""
@@ -51,7 +50,7 @@ def assert_payment(self, invoice, account):
5150
class Braintree:
5251
"""API for braintree"""
5352

54-
def __init__(self, merchant_id, public_key, private_key):
53+
def __init__(self, merchant_id, public_key, private_key, provider_account_id):
5554
self.gateway = braintree.BraintreeGateway(
5655
braintree.Configuration(
5756
environment=braintree.Environment.Sandbox,
@@ -60,6 +59,7 @@ def __init__(self, merchant_id, public_key, private_key):
6059
private_key=private_key,
6160
)
6261
)
62+
self.provider_account_id = provider_account_id
6363

6464
@backoff.on_exception(backoff.fibo, (ServiceUnavailableError, RequestTimeoutError), max_tries=8, jitter=None)
6565
def get_customer_transactions(self, account):
@@ -76,10 +76,9 @@ def merchant_currency(self):
7676
merchant_accounts = list(self.gateway.merchant_account.all().merchant_accounts.items)
7777
return [x for x in merchant_accounts if x.default is True][0].currency_iso_code
7878

79-
@staticmethod
80-
def customer_id(account):
81-
"""Returns Braintree customer id. It is in a form `3scale-2-{account_id}-1`"""
82-
return f"3scale-2-{account.entity_id}-1"
79+
def customer_id(self, account):
80+
"""Returns Braintree customer id. It is in a form `3scale-{provider_id}-{account_id}-1`"""
81+
return f"3scale-{self.provider_account_id}-{account.entity_id}-1"
8382

8483
@staticmethod
8584
def _assert_transaction(invoice, transaction):

testsuite/capabilities/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88

99
import enum
10-
from typing import Set, Callable, Any, Tuple, List
10+
from typing import Any, Callable, List, Set, Tuple
1111

1212
# Users should have access only to these public methods/decorators
1313
__all__ = ["CapabilityRegistry", "Capability"]

testsuite/capabilities/providers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""This module is where most of the capability providers should be to not have them scattered around"""
22

33
from testsuite import gateways
4-
from testsuite.capabilities import CapabilityRegistry, Capability
5-
from testsuite.configuration import openshift
4+
from testsuite.capabilities import Capability, CapabilityRegistry
65
from testsuite.config import settings
6+
from testsuite.configuration import openshift
77

88

99
def gateway_capabilities():

testsuite/certificates/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Collection of classes for working with different ssl certificate tools."""
22

33
from abc import ABC, abstractmethod
4-
from typing import List, Optional, Tuple, Dict
4+
from typing import Dict, List, Optional, Tuple
55

66
from testsuite.certificates.persist import TmpFilePersist
77

0 commit comments

Comments
 (0)