Skip to content

Commit 63c9663

Browse files
committed
[feature/PI-590-path_alias] path aliases
1 parent 86fffb3 commit 63c9663

15 files changed

+395
-50
lines changed

src/api/readDevice/src/v1/steps.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,28 @@ def read_product_team(data, cache) -> ProductTeam:
2828

2929
def read_product(data, cache) -> CpmProduct:
3030
path_params: DevicePathParams = data[parse_path_params]
31+
product_team: ProductTeam = data[read_product_team]
32+
3133
product_repo = CpmProductRepository(
3234
table_name=cache["DYNAMODB_TABLE"], dynamodb_client=cache["DYNAMODB_CLIENT"]
3335
)
3436
cpm_product = product_repo.read(
35-
id=path_params.product_id, product_team_id=path_params.product_team_id
37+
product_team_id=product_team.id, id=path_params.product_id
3638
)
3739
return cpm_product
3840

3941

4042
def read_device(data, cache) -> Device:
4143
path_params: DevicePathParams = data[parse_path_params]
44+
product_team: ProductTeam = data[read_product_team]
45+
product: CpmProduct = data[read_product]
46+
4247
device_repo = DeviceRepository(
4348
table_name=cache["DYNAMODB_TABLE"], dynamodb_client=cache["DYNAMODB_CLIENT"]
4449
)
4550
return device_repo.read(
46-
product_team_id=path_params.product_team_id,
47-
product_id=path_params.product_id,
51+
product_team_id=product_team.id,
52+
product_id=product.id,
4853
id=path_params.device_id,
4954
)
5055

src/api/readDeviceReferenceData/src/v1/steps.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,29 @@ def read_product_team(data, cache) -> ProductTeam:
3030

3131
def read_product(data, cache) -> CpmProduct:
3232
path_params: DeviceReferenceDataPathParams = data[parse_path_params]
33+
product_team: ProductTeam = data[read_product_team]
34+
3335
product_repo = CpmProductRepository(
3436
table_name=cache["DYNAMODB_TABLE"], dynamodb_client=cache["DYNAMODB_CLIENT"]
3537
)
3638
cpm_product = product_repo.read(
37-
id=path_params.product_id, product_team_id=path_params.product_team_id
39+
product_team_id=product_team.id,
40+
id=path_params.product_id,
3841
)
3942
return cpm_product
4043

4144

4245
def read_device_reference_data(data, cache) -> DeviceReferenceData:
4346
path_params: DeviceReferenceDataPathParams = data[parse_path_params]
47+
product_team: ProductTeam = data[read_product_team]
48+
product: CpmProduct = data[read_product]
49+
4450
device_reference_data_repo = DeviceReferenceDataRepository(
4551
table_name=cache["DYNAMODB_TABLE"], dynamodb_client=cache["DYNAMODB_CLIENT"]
4652
)
4753
return device_reference_data_repo.read(
48-
product_id=path_params.product_id,
49-
product_team_id=path_params.product_team_id,
54+
product_team_id=product_team.id,
55+
product_id=product.id,
5056
id=path_params.device_reference_data_id,
5157
)
5258

src/api/searchCpmProduct/src/v1/steps.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from http import HTTPStatus
22

33
from aws_lambda_powertools.utilities.data_classes import APIGatewayProxyEvent
4+
from domain.core.product_team.v3 import ProductTeam
45
from domain.repository.cpm_product_repository.v3 import CpmProductRepository
56
from domain.repository.product_team_repository.v2 import ProductTeamRepository
67
from domain.response.response_models import SearchResponse
@@ -12,7 +13,7 @@ def parse_incoming_path_parameters(data, cache) -> str:
1213
return event.path_parameters["product_team_id"]
1314

1415

15-
def validate_product_team(data, cache) -> str:
16+
def read_product_team(data, cache) -> ProductTeam:
1617
product_team_repo = ProductTeamRepository(
1718
table_name=cache["DYNAMODB_TABLE"], dynamodb_client=cache["DYNAMODB_CLIENT"]
1819
)
@@ -21,11 +22,12 @@ def validate_product_team(data, cache) -> str:
2122

2223

2324
def query_products(data, cache) -> list:
24-
product_team_id = data[parse_incoming_path_parameters]
25+
product_team: ProductTeam = data[read_product_team]
26+
2527
cpm_product_repo = CpmProductRepository(
2628
table_name=cache["DYNAMODB_TABLE"], dynamodb_client=cache["DYNAMODB_CLIENT"]
2729
)
28-
results = cpm_product_repo.search(product_team_id=product_team_id)
30+
results = cpm_product_repo.search(product_team_id=product_team.id)
2931
return results
3032

3133

@@ -37,7 +39,7 @@ def return_products(data, cache) -> tuple[HTTPStatus, str]:
3739

3840
steps = [
3941
parse_incoming_path_parameters,
40-
validate_product_team,
42+
read_product_team,
4143
query_products,
4244
return_products,
4345
]

src/api/tests/feature_tests/features/createCpmProduct.success.feature

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ Feature: Create CPM Product - success scenarios
77
| version | 1 |
88
| Authorization | letmein |
99

10-
Scenario: Successfully create a CPM Product
10+
Scenario Outline: Successfully create a CPM Product
1111
Given I have already made a "POST" request with "default" headers to "ProductTeam" with body:
1212
| path | value |
1313
| name | My Great Product Team |
1414
| ods_code | F5H1R |
1515
| keys.0.key_type | product_team_id_alias |
1616
| keys.0.key_value | FOOBAR |
1717
Given I note the response field "$.id" as "product_team_id"
18-
When I make a "POST" request with "default" headers to "ProductTeam/${ note(product_team_id) }/Product" with body:
18+
When I make a "POST" request with "default" headers to "ProductTeam/<product_team_id>/Product" with body:
1919
| path | value |
2020
| name | My Great Product |
2121
And I note the response field "$.id" as "product_id"
@@ -50,3 +50,8 @@ Feature: Create CPM Product - success scenarios
5050
| name | value |
5151
| Content-Type | application/json |
5252
| Content-Length | 255 |
53+
54+
Examples:
55+
| product_team_id |
56+
| ${ note(product_team_id) } |
57+
| FOOBAR |

src/api/tests/feature_tests/features/createCpmProductForEpr.success.feature

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ Feature: Create CPM Product for EPR - success scenarios
77
| version | 1 |
88
| Authorization | letmein |
99

10-
Scenario: Successfully create a CPM Product for EPR
10+
Scenario Outline: Successfully create a CPM Product for EPR
1111
Given I have already made a "POST" request with "default" headers to "ProductTeam" with body:
1212
| path | value |
1313
| name | My Great Product Team |
1414
| ods_code | F5H1R |
1515
| keys.0.key_type | product_team_id_alias |
1616
| keys.0.key_value | FOOBAR |
1717
Given I note the response field "$.id" as "product_team_id"
18-
When I make a "POST" request with "default" headers to "ProductTeam/${ note(product_team_id) }/Product/Epr" with body:
18+
When I make a "POST" request with "default" headers to "ProductTeam/<product_team_id>/Product/Epr" with body:
1919
| path | value |
2020
| name | My Great Product |
2121
Then I receive a status code "201" with body
@@ -53,6 +53,11 @@ Feature: Create CPM Product for EPR - success scenarios
5353
| Content-Type | application/json |
5454
| Content-Length | 339 |
5555

56+
Examples:
57+
| product_team_id |
58+
| ${ note(product_team_id) } |
59+
| FOOBAR |
60+
5661
Scenario: Successfully create two CPM Products for EPR with the same ProductTeam
5762
Given I have already made a "POST" request with "default" headers to "ProductTeam" with body:
5863
| path | value |

src/api/tests/feature_tests/features/createDevice.success.feature

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ Feature: Create Device - success scenarios
77
| version | 1 |
88
| Authorization | letmein |
99

10-
Scenario: Successfully create a Device
10+
Scenario Outline: Successfully create a Device
1111
Given I have already made a "POST" request with "default" headers to "ProductTeam" with body:
12-
| path | value |
13-
| name | My Great Product Team |
14-
| ods_code | F5H1R |
12+
| path | value |
13+
| name | My Great Product Team |
14+
| ods_code | F5H1R |
15+
| keys.0.key_type | product_team_id_alias |
16+
| keys.0.key_value | FOOBAR |
1517
And I note the response field "$.id" as "product_team_id"
16-
And I have already made a "POST" request with "default" headers to "ProductTeam/${ note(product_team_id) }/Product" with body:
18+
And I have already made a "POST" request with "default" headers to "ProductTeam/<product_team_id>/Product" with body:
1719
| path | value |
1820
| name | My Great Product |
1921
And I note the response field "$.id" as "product_id"
20-
When I make a "POST" request with "default" headers to "ProductTeam/${ note(product_team_id) }/Product/${ note(product_id) }/Device" with body:
22+
When I make a "POST" request with "default" headers to "ProductTeam/<product_team_id>/Product/${ note(product_id) }/Device" with body:
2123
| path | value |
2224
| name | My Device |
2325
Then I receive a status code "201" with body
@@ -58,3 +60,70 @@ Feature: Create Device - success scenarios
5860
| name | value |
5961
| Content-Type | application/json |
6062
| Content-Length | 345 |
63+
64+
Examples:
65+
| product_team_id |
66+
| ${ note(product_team_id) } |
67+
| FOOBAR |
68+
69+
Scenario Outline: Successfully create a Device with an EPR Product
70+
Given I have already made a "POST" request with "default" headers to "ProductTeam" with body:
71+
| path | value |
72+
| name | My Great Product Team |
73+
| ods_code | F5H1R |
74+
| keys.0.key_type | product_team_id_alias |
75+
| keys.0.key_value | FOOBAR |
76+
And I note the response field "$.id" as "product_team_id"
77+
And I have already made a "POST" request with "default" headers to "ProductTeam/<product_team_id>/Product/Epr" with body:
78+
| path | value |
79+
| name | My Great Product |
80+
And I note the response field "$.id" as "product_id"
81+
And I note the response field "$.keys.0.key_value" as "party_key"
82+
When I make a "POST" request with "default" headers to "ProductTeam/<product_team_id>/Product/<product_id>/Device" with body:
83+
| path | value |
84+
| name | My Device |
85+
Then I receive a status code "201" with body
86+
| path | value |
87+
| id | << ignore >> |
88+
| name | My Device |
89+
| status | active |
90+
| product_id | ${ note(product_id) } |
91+
| product_team_id | ${ note(product_team_id) } |
92+
| ods_code | F5H1R |
93+
| created_on | << ignore >> |
94+
| updated_on | << ignore >> |
95+
| deleted_on | << ignore >> |
96+
| keys | [] |
97+
| tags | [] |
98+
| questionnaire_responses | << ignore >> |
99+
And the response headers contain:
100+
| name | value |
101+
| Content-Type | application/json |
102+
| Content-Length | 345 |
103+
And I note the response field "$.id" as "device_id"
104+
When I make a "GET" request with "default" headers to "ProductTeam/${ note(product_team_id) }/Product/${ note(product_id) }/Device/${ note(device_id) }"
105+
Then I receive a status code "200" with body
106+
| path | value |
107+
| id | ${ note(device_id) } |
108+
| name | My Device |
109+
| status | active |
110+
| product_id | ${ note(product_id) } |
111+
| product_team_id | ${ note(product_team_id) } |
112+
| ods_code | F5H1R |
113+
| created_on | << ignore >> |
114+
| updated_on | << ignore >> |
115+
| deleted_on | << ignore >> |
116+
| keys | [] |
117+
| tags | [] |
118+
| questionnaire_responses | << ignore >> |
119+
And the response headers contain:
120+
| name | value |
121+
| Content-Type | application/json |
122+
| Content-Length | 345 |
123+
124+
Examples:
125+
| product_team_id | product_id |
126+
| ${ note(product_team_id) } | ${ note(product_id) } |
127+
| ${ note(product_team_id) } | ${ note(party_key) } |
128+
| FOOBAR | ${ note(product_id) } |
129+
| FOOBAR | ${ note(party_key) } |

src/api/tests/feature_tests/features/createDeviceReferenceData.success.feature

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ Feature: Create Device Reference Data - success scenarios
77
| version | 1 |
88
| Authorization | letmein |
99

10-
Scenario: Successfully create a Device Reference Data
10+
Scenario Outline: Successfully create a Device Reference Data
1111
Given I have already made a "POST" request with "default" headers to "ProductTeam" with body:
12-
| path | value |
13-
| name | My Great Product Team |
14-
| ods_code | F5H1R |
12+
| path | value |
13+
| name | My Great Product Team |
14+
| ods_code | F5H1R |
15+
| keys.0.key_type | product_team_id_alias |
16+
| keys.0.key_value | FOOBAR |
1517
And I note the response field "$.id" as "product_team_id"
16-
And I have already made a "POST" request with "default" headers to "ProductTeam/${ note(product_team_id) }/Product" with body:
18+
And I have already made a "POST" request with "default" headers to "ProductTeam/<product_team_id>/Product" with body:
1719
| path | value |
1820
| name | My Great Product |
1921
And I note the response field "$.id" as "product_id"
20-
When I make a "POST" request with "default" headers to "ProductTeam/${ note(product_team_id) }/Product/${ note(product_id) }/DeviceReferenceData" with body:
22+
When I make a "POST" request with "default" headers to "ProductTeam/<product_team_id>/Product/${ note(product_id) }/DeviceReferenceData" with body:
2123
| path | value |
2224
| name | My Device Reference Data |
2325
Then I receive a status code "201" with body
@@ -52,3 +54,64 @@ Feature: Create Device Reference Data - success scenarios
5254
| name | value |
5355
| Content-Type | application/json |
5456
| Content-Length | 316 |
57+
58+
Examples:
59+
| product_team_id |
60+
| ${ note(product_team_id) } |
61+
| FOOBAR |
62+
63+
Scenario Outline: Successfully create a DeviceReferenceData with an EPR Product
64+
Given I have already made a "POST" request with "default" headers to "ProductTeam" with body:
65+
| path | value |
66+
| name | My Great Product Team |
67+
| ods_code | F5H1R |
68+
| keys.0.key_type | product_team_id_alias |
69+
| keys.0.key_value | FOOBAR |
70+
And I note the response field "$.id" as "product_team_id"
71+
And I have already made a "POST" request with "default" headers to "ProductTeam/<product_team_id>/Product/Epr" with body:
72+
| path | value |
73+
| name | My Great Product |
74+
And I note the response field "$.id" as "product_id"
75+
And I note the response field "$.keys.0.key_value" as "party_key"
76+
When I make a "POST" request with "default" headers to "ProductTeam/<product_team_id>/Product/<product_id>/DeviceReferenceData" with body:
77+
| path | value |
78+
| name | My Device Reference Data |
79+
Then I receive a status code "201" with body
80+
| path | value |
81+
| id | << ignore >> |
82+
| name | My Device Reference Data |
83+
| product_id | ${ note(product_id) } |
84+
| product_team_id | ${ note(product_team_id) } |
85+
| ods_code | F5H1R |
86+
| created_on | << ignore >> |
87+
| updated_on | << ignore >> |
88+
| deleted_on | << ignore >> |
89+
| questionnaire_responses | {} |
90+
And the response headers contain:
91+
| name | value |
92+
| Content-Type | application/json |
93+
| Content-Length | 316 |
94+
And I note the response field "$.id" as "device_reference_data_id"
95+
When I make a "GET" request with "default" headers to "ProductTeam/${ note(product_team_id) }/Product/${ note(product_id) }/DeviceReferenceData/${ note(device_reference_data_id) }"
96+
Then I receive a status code "200" with body
97+
| path | value |
98+
| id | ${ note(device_reference_data_id) } |
99+
| name | My Device Reference Data |
100+
| product_id | ${ note(product_id) } |
101+
| product_team_id | ${ note(product_team_id) } |
102+
| ods_code | F5H1R |
103+
| created_on | << ignore >> |
104+
| updated_on | << ignore >> |
105+
| deleted_on | << ignore >> |
106+
| questionnaire_responses | {} |
107+
And the response headers contain:
108+
| name | value |
109+
| Content-Type | application/json |
110+
| Content-Length | 316 |
111+
112+
Examples:
113+
| product_team_id | product_id |
114+
| ${ note(product_team_id) } | ${ note(product_id) } |
115+
| ${ note(product_team_id) } | ${ note(party_key) } |
116+
| FOOBAR | ${ note(product_id) } |
117+
| FOOBAR | ${ note(party_key) } |

0 commit comments

Comments
 (0)