Skip to content

Commit 5d7b9c8

Browse files
committed
Unit and integration tests
1 parent 1cfaa68 commit 5d7b9c8

File tree

19 files changed

+95
-67
lines changed

19 files changed

+95
-67
lines changed

src/api/createCpmProduct/tests/data.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
product_team_payload = {
2-
"keys": [{"key_type": "product_team_id_alias", "key_value": "BAR"}],
2+
"keys": [
3+
{
4+
"key_type": "product_team_id",
5+
"key_value": "808a36db-a52a-4130-b71e-d9cbcbaed15b",
6+
}
7+
],
38
"ods_code": "F5H1R",
49
"name": "FOOBAR Product Team",
510
}

src/api/createCpmProduct/tests/test_index.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_index(version):
6161
expected_body = json.dumps(
6262
{
6363
"id": product["id"],
64-
"product_team_id": product["product_team_id"],
64+
"cpm_product_team_id": product["cpm_product_team_id"],
6565
"name": "Foobar product",
6666
"ods_code": "F5H1R",
6767
"status": "active",
@@ -127,15 +127,17 @@ def test_index_no_such_product_team(version):
127127
event={
128128
"headers": {"version": version},
129129
"body": json.dumps(product_payload),
130-
"pathParameters": {"product_team_id": "FOOBAR"},
130+
"pathParameters": {
131+
"product_team_id": "808a36db-a52a-4130-b71e-d9cbcbaed15b"
132+
},
131133
}
132134
)
133135
expected_result = json.dumps(
134136
{
135137
"errors": [
136138
{
137139
"code": "RESOURCE_NOT_FOUND",
138-
"message": "Could not find ProductTeam for key ('FOOBAR')",
140+
"message": "Could not find ProductTeam for key ('808a36db-a52a-4130-b71e-d9cbcbaed15b')",
139141
}
140142
],
141143
}

src/api/createProductTeam/tests/v1/test_index_v1.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ def test_index(version):
4848
"created_on": result_body["created_on"],
4949
"updated_on": None,
5050
"deleted_on": None,
51-
"keys": [{"key_type": "product_team_id_alias", "key_value": "BAR"}],
51+
"keys": [
52+
{
53+
"key_type": "product_team_id",
54+
"key_value": "808a36db-a52a-4130-b71e-d9cbcbaed15b",
55+
}
56+
],
5257
}
5358
)
5459
expected = {
@@ -146,7 +151,12 @@ def test_index(version):
146151
"created_on": result_body["created_on"],
147152
"updated_on": None,
148153
"deleted_on": None,
149-
"keys": [{"key_type": "product_team_id_alias", "key_value": "BAR"}],
154+
"keys": [
155+
{
156+
"key_type": "product_team_id",
157+
"key_value": "808a36db-a52a-4130-b71e-d9cbcbaed15b",
158+
}
159+
],
150160
}
151161
)
152162
expected = {

src/api/deleteCpmProduct/tests/test_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def test_index():
101101
assert deleted_product == {
102102
"name": PRODUCT_NAME,
103103
"ods_code": ODS_CODE,
104-
"product_team_id": product_team.id,
104+
"cpm_product_team_id": product_team.id,
105105
"status": Status.INACTIVE,
106106
"keys": [],
107107
}

src/api/deleteProductTeam/tests/test_index.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ def test_index_by_alias(version):
152152
result = handler(
153153
event={
154154
"headers": {"version": version},
155-
"pathParameters": {"product_team_id": "BAR"},
155+
"pathParameters": {
156+
"product_team_id": "808a36db-a52a-4130-b71e-d9cbcbaed15b"
157+
},
156158
}
157159
)
158160
expected_result = json.dumps(

src/api/readCpmProduct/tests/test_index.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
PRODUCT_TEAM_NAME = "product-team-name"
1818
PRODUCT_ID = "P.XXX-YYY"
1919
PRODUCT_NAME = "cpm-product-name"
20-
PRODUCT_TEAM_KEYS = [{"key_type": "product_team_id_alias", "key_value": "BAR"}]
20+
PRODUCT_TEAM_KEYS = [
21+
{"key_type": "product_team_id", "key_value": "808a36db-a52a-4130-b71e-d9cbcbaed15b"}
22+
]
2123

2224

2325
@pytest.mark.parametrize(
@@ -67,14 +69,14 @@ def test_index(version):
6769

6870
# Assertions for fields that must exactly match
6971
assert response_body["id"] == PRODUCT_ID
70-
assert response_body["product_team_id"] == product_team.id
72+
assert response_body["cpm_product_team_id"] == product_team.id
7173
assert response_body["name"] == PRODUCT_NAME
7274
assert response_body["ods_code"] == ODS_CODE
7375
assert response_body["updated_on"] is None
7476
assert response_body["deleted_on"] is None
7577

7678
# Assertions for fields that only need to be included
77-
assert "product_team_id" in response_body
79+
assert "cpm_product_team_id" in response_body
7880
assert "created_on" in response_body
7981

8082
expected_headers = {

src/api/readProductTeam/tests/test_index.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ def test_index(version):
6060
"created_on": result_body["created_on"],
6161
"updated_on": None,
6262
"deleted_on": None,
63-
"keys": [{"key_type": "product_team_id_alias", "key_value": "BAR"}],
63+
"keys": [
64+
{
65+
"key_type": "product_team_id",
66+
"key_value": "808a36db-a52a-4130-b71e-d9cbcbaed15b",
67+
}
68+
],
6469
}
6570
)
6671

@@ -159,7 +164,9 @@ def test_index_by_alias(version):
159164
result = handler(
160165
event={
161166
"headers": {"version": version},
162-
"pathParameters": {"product_team_id": "BAR"},
167+
"pathParameters": {
168+
"product_team_id": "808a36db-a52a-4130-b71e-d9cbcbaed15b"
169+
},
163170
}
164171
)
165172
result_body = json_loads(result["body"])
@@ -172,7 +179,12 @@ def test_index_by_alias(version):
172179
"created_on": result_body["created_on"],
173180
"updated_on": None,
174181
"deleted_on": None,
175-
"keys": [{"key_type": "product_team_id_alias", "key_value": "BAR"}],
182+
"keys": [
183+
{
184+
"key_type": "product_team_id",
185+
"key_value": "808a36db-a52a-4130-b71e-d9cbcbaed15b",
186+
}
187+
],
176188
}
177189
)
178190

src/api/searchProduct/tests/test_index.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
ODS_CODE = "F5H1R"
1818
PRODUCT_TEAM_NAME = "product-team-name"
1919
PRODUCT_TEAM_ID = "sample_product_team_id"
20-
PRODUCT_TEAM_KEYS = [{"key_type": "product_team_id_alias", "key_value": "FOOBAR"}]
20+
PRODUCT_TEAM_KEYS = [
21+
{"key_type": "product_team_id", "key_value": "808a36db-a52a-4130-b71e-d9cbcbaed15b"}
22+
]
2123
PRODUCT_NAME = "product-name"
2224
PRODUCT_ID = "P.AAA-367"
2325

@@ -191,7 +193,7 @@ def test_search_by_product_team_alias():
191193
)
192194
product_repo.write(cpm_product)
193195

194-
params = {"product_team_id": "FOOBAR"}
196+
params = {"product_team_id": "808a36db-a52a-4130-b71e-d9cbcbaed15b"}
195197
result = handler(
196198
event={
197199
"headers": {"version": VERSION},

src/layers/domain/api/common_steps/tests/test_create_cpm_product.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@ def test_create_product_steps_good_input():
8181
step_chain.run(init=event, cache=mocked_cache)
8282

8383
assert isinstance(step_chain.result, CpmProduct)
84-
assert step_chain.result.product_team_id == product_team.id
84+
assert step_chain.result.cpm_product_team_id == product_team.id
8585
assert step_chain.result.ods_code == ods_code

src/layers/domain/api/common_steps/tests/test_read_cpm_product.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,5 @@ def test_read_product_steps_good_input():
7575
)
7676

7777
assert isinstance(step_chain.result, CpmProduct)
78-
assert step_chain.result.product_team_id == product_team.id
78+
assert step_chain.result.cpm_product_team_id == product_team.id
7979
assert step_chain.result.ods_code == ods_code

0 commit comments

Comments
 (0)