Skip to content

Commit 0ca2882

Browse files
committed
Merge branch 'feature/PI-870-sonarcloud_stuff' into release/2025-04-01
2 parents a880ee6 + ab503ed commit 0ca2882

File tree

15 files changed

+50
-81
lines changed

15 files changed

+50
-81
lines changed

src/api/tests/feature_tests/environment.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,6 @@ def before_feature(context: Context, feature: Feature):
8282
name=feature.name,
8383
description=" ".join(feature.description),
8484
)
85-
cpm_scenarios = [
86-
"Create Product Team - success scenarios",
87-
"Create Product Team - failure scenarios",
88-
"Read Product Team - success scenarios",
89-
"Read Product Team - failure scenarios",
90-
"Delete Product Team - success scenarios",
91-
"Delete Product Team - failure scenarios",
92-
"Create CPM Product - success scenarios",
93-
"Create CPM Product - failure scenarios",
94-
"Read CPM Product - success scenarios",
95-
"Read CPM Product - failure scenarios",
96-
"Delete CPM Product - success scenarios",
97-
"Delete CPM Product - failure scenarios",
98-
"Search Products - success scenarios",
99-
"Search Products - failures scenarios",
100-
]
10185
if context.test_mode is TestMode.INTEGRATION:
10286
table = "dynamodb_cpm_table_name.value"
10387
context.table_name = read_terraform_output(table)

src/api/tests/feature_tests/steps/context.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from contextlib import AbstractContextManager
22
from dataclasses import dataclass
3+
from typing import Optional
34

45
from behave.model import Table
56
from behave.runner import Context as BehaveContext
@@ -17,19 +18,19 @@
1718
@dataclass
1819
class Context(BehaveContext):
1920
base_url: str
20-
headers: dict[str, dict[str, str]] = None
21-
response: Response = None
22-
table: Table = None
23-
test_mode: TestMode = None
24-
table_name: str = None
25-
session: AbstractContextManager = None
26-
dynamodb_client: DynamoDBClient = None
27-
workspace: str = None
28-
environment: str = None
29-
workspace_type: str = None
30-
api_key: str = None
31-
notes: dict[str, str] = None
32-
postman_endpoint: str = None
21+
headers: Optional[dict[str, dict[str, str]]]
22+
response: Optional[Response]
23+
table: Optional[Table]
24+
test_mode: Optional[TestMode]
25+
table_name: Optional[str]
26+
session: Optional[AbstractContextManager]
27+
dynamodb_client: Optional[DynamoDBClient]
28+
workspace: Optional[str]
29+
environment: Optional[str]
30+
workspace_type: Optional[str]
31+
api_key: Optional[str]
32+
notes: Optional[dict[str, str]]
33+
postman_endpoint: Optional[str]
3334

3435
postman_collection: PostmanCollection = None
3536
postman_feature: PostmanItem = None

src/api/tests/feature_tests/steps/requests.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json as _json
2-
import time
32
from contextlib import contextmanager
43
from dataclasses import dataclass
54
from unittest import mock
@@ -9,7 +8,6 @@
98
from domain.response.aws_lambda_response import AwsLambdaResponse
109
from event.json import json_loads
1110
from requests import HTTPError, Response, request
12-
from requests.exceptions import SSLError
1311

1412
from api.tests.feature_tests.steps.data import DUMMY_CONTEXT
1513
from api.tests.feature_tests.steps.endpoint_lambda_mapping import (
@@ -35,21 +33,6 @@ def _parse_url(base_url: str, endpoint: str) -> str:
3533
return url
3634

3735

38-
@contextmanager
39-
def retry_on_ssl_error(sleep_time: int = 3, max_retries=5):
40-
retries = 0
41-
while True:
42-
try:
43-
yield
44-
except SSLError:
45-
if retries == max_retries:
46-
raise
47-
time.sleep(sleep_time)
48-
retries += 1
49-
finally:
50-
break
51-
52-
5336
def make_request(
5437
base_url: str,
5538
http_method: str,
@@ -62,10 +45,9 @@ def make_request(
6245
json = body if type(body) is dict else None
6346
data = None if type(body) is dict else body
6447

65-
with retry_on_ssl_error():
66-
response = request(
67-
method=http_method, url=url, headers=headers, json=json, data=data
68-
)
48+
response = request(
49+
method=http_method, url=url, headers=headers, json=json, data=data
50+
)
6951

7052
if raise_for_status:
7153
try:

src/layers/api_utils/api_step_chain/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from types import ModuleType
22

3-
from api_utils.versioning.constants import VERSIONING_STEP_ARGS
3+
from api_utils.versioning.constants import VersioningStepArgs
44
from api_utils.versioning.steps import (
55
get_largest_possible_version,
66
get_steps_for_requested_version,
@@ -27,8 +27,8 @@ def execute_step_chain(
2727
)
2828
version_chain.run(
2929
init={
30-
VERSIONING_STEP_ARGS.EVENT: event,
31-
VERSIONING_STEP_ARGS.VERSIONED_STEPS: versioned_steps,
30+
VersioningStepArgs.EVENT: event,
31+
VersioningStepArgs.VERSIONED_STEPS: versioned_steps,
3232
}
3333
)
3434

src/layers/api_utils/versioning/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
VERSION_RE = re.compile(r"^v(\d+)$")
44

55

6-
class VERSIONING_STEP_ARGS:
6+
class VersioningStepArgs:
77
VERSIONED_STEPS = "versioned_steps"
88
EVENT = "event"

src/layers/api_utils/versioning/steps.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
from domain.response.validation_errors import mark_validation_errors_as_inbound
55
from event.step_chain import StepChain
66

7-
from .constants import VERSIONING_STEP_ARGS
7+
from .constants import VersioningStepArgs
88
from .errors import VersionException
99
from .models import Event
1010

1111

1212
@mark_validation_errors_as_inbound
1313
def get_requested_version(data, cache=None):
14-
event = Event(**data[StepChain.INIT][VERSIONING_STEP_ARGS.EVENT])
14+
event = Event(**data[StepChain.INIT][VersioningStepArgs.EVENT])
1515
return event.headers.version
1616

1717

1818
def get_largest_possible_version(data, cache=None) -> str:
1919
requested_version = data[get_requested_version]
20-
possible_versions = data[StepChain.INIT][VERSIONING_STEP_ARGS.VERSIONED_STEPS]
20+
possible_versions = data[StepChain.INIT][VersioningStepArgs.VERSIONED_STEPS]
2121
integer_versions = map(int, possible_versions)
2222
possible_versions = [
2323
version
@@ -31,7 +31,7 @@ def get_largest_possible_version(data, cache=None) -> str:
3131

3232

3333
def get_steps_for_requested_version(data, cache=None):
34-
steps_by_version = data[StepChain.INIT][VERSIONING_STEP_ARGS.VERSIONED_STEPS]
34+
steps_by_version = data[StepChain.INIT][VersioningStepArgs.VERSIONED_STEPS]
3535
largest_possible_version = data[get_largest_possible_version]
3636
return steps_by_version[largest_possible_version]
3737

src/layers/api_utils/versioning/tests/test_steps.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from pathlib import Path
22

33
import pytest
4-
from api_utils.versioning.constants import VERSIONING_STEP_ARGS
4+
from api_utils.versioning.constants import VersioningStepArgs
55
from api_utils.versioning.errors import VersionException
66
from api_utils.versioning.models import Event
77
from api_utils.versioning.steps import (
@@ -53,9 +53,7 @@ def test_largest_possible_version(requested_version: str, expected_version: str)
5353
data=step_data(
5454
kwargs={
5555
get_requested_version: requested_version,
56-
StepChain.INIT: {
57-
VERSIONING_STEP_ARGS.VERSIONED_STEPS: handler_versions
58-
},
56+
StepChain.INIT: {VersioningStepArgs.VERSIONED_STEPS: handler_versions},
5957
}
6058
)
6159
)
@@ -72,7 +70,7 @@ def test_largest_possible_version_error(requested_version: str):
7270
kwargs={
7371
get_requested_version: requested_version,
7472
StepChain.INIT: {
75-
VERSIONING_STEP_ARGS.VERSIONED_STEPS: handler_versions
73+
VersioningStepArgs.VERSIONED_STEPS: handler_versions
7674
},
7775
}
7876
)

src/layers/api_utils/versioning/tests/test_steps_e2e.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from types import FunctionType
22

33
import pytest
4-
from api_utils.versioning.constants import VERSIONING_STEP_ARGS
4+
from api_utils.versioning.constants import VersioningStepArgs
55
from api_utils.versioning.models import Event, VersionHeader
66
from api_utils.versioning.steps import versioning_steps
77
from domain.logging.step_decorators import logging_step_decorators
@@ -48,8 +48,8 @@ def test_versioning_steps(requested_version: str, expected_steps: list[FunctionT
4848
)
4949
step_chain.run(
5050
init={
51-
VERSIONING_STEP_ARGS.EVENT: _event.dict(),
52-
VERSIONING_STEP_ARGS.VERSIONED_STEPS: versioned_steps,
51+
VersioningStepArgs.EVENT: _event.dict(),
52+
VersioningStepArgs.VERSIONED_STEPS: versioned_steps,
5353
}
5454
)
5555
assert step_chain.result is expected_steps

src/layers/domain/core/cpm_product/v1.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from datetime import datetime
2+
from typing import Optional
23

3-
from attr import dataclass
4+
from attr import dataclass, field
45
from domain.core.aggregate_root import UPDATED_ON, AggregateRoot, event
56
from domain.core.cpm_system_id import ProductId
67
from domain.core.enum import Status
@@ -21,8 +22,8 @@ class CpmProductCreatedEvent(Event):
2122
ods_code: str
2223
status: Status
2324
created_on: str
24-
updated_on: str = None
25-
deleted_on: str = None
25+
updated_on: Optional[str]
26+
deleted_on: Optional[str]
2627

2728

2829
@dataclass(kw_only=True, slots=True)
@@ -35,8 +36,8 @@ class CpmProductKeyAddedEvent(Event):
3536
ods_code: str
3637
status: Status
3738
created_on: str
38-
updated_on: str = None
39-
deleted_on: str = None
39+
updated_on: Optional[str] = field(default=None)
40+
deleted_on: Optional[str] = field(default=None)
4041
keys: list[dict]
4142

4243

src/layers/domain/core/cpm_system_id/v1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from datetime import datetime
66
from functools import cache
77
from pathlib import Path
8+
from typing import Optional
89
from uuid import uuid4
910

1011
from domain.core.base import BaseModel
@@ -34,7 +35,7 @@ def _load_existing_ids():
3435

3536

3637
class CpmSystemId(BaseModel, ABC):
37-
__root__: str = None
38+
__root__: Optional[str]
3839

3940
@classmethod
4041
@abstractmethod

0 commit comments

Comments
 (0)