Skip to content

Commit d695a2d

Browse files
authored
Merge pull request #495 from NHSDigital/release/2025-02-13
Release/2025 02 13
2 parents 93a653e + 473c918 commit d695a2d

File tree

14 files changed

+69
-68
lines changed

14 files changed

+69
-68
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 2025-02-13
4+
- [PI-767] Table design change
5+
36
## 2025-02-12
47
- [PI-762] UI Demo POC
58

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025.02.12
1+
2025.02.13

changelog/2025-02-13.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- [PI-767] Table design change

infrastructure/swagger/05_paths.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ paths:
315315
description: |
316316
- Delete a product using a product team ID and product ID.
317317
tags:
318-
- Core Product ID Endpointsurce (DELETE)
318+
- Core Product ID Endpoints
319319
parameters:
320320
- $ref: "#/components/parameters/ProductTeamId"
321321
- $ref: "#/components/parameters/ProductId"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "connecting-party-manager"
3-
version = "2025.02.12"
3+
version = "2025.02.13"
44
description = "Repository for the Connecting Party Manager API and related services"
55
authors = ["NHS England"]
66
license = "LICENSE.md"

src/api/readCpmProduct/tests/test_index.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
TABLE_NAME = "hiya"
1515
ODS_CODE = "F5H1R"
16-
PRODUCT_TEAM_ID = "F5H1R.641be376-3954-4339-822c-54071c9ff1a0"
16+
PRODUCT_TEAM_ID = "641be376-3954-4339-822c-54071c9ff1a0"
1717
PRODUCT_TEAM_NAME = "product-team-name"
1818
PRODUCT_ID = "P.XXX-YYY"
1919
PRODUCT_NAME = "cpm-product-name"
@@ -64,7 +64,6 @@ def test_index(version):
6464
},
6565
}
6666
)
67-
6867
response_body = json_loads(result["body"])
6968

7069
# Assertions for fields that must exactly match

src/api/readProductTeam/tests/test_index.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
)
2424
def test_index(version):
2525
org = Root.create_ods_organisation(ods_code=CPM_PRODUCT_TEAM_NO_ID["ods_code"])
26-
product_team = org.create_product_team_epr(
26+
product_team = org.create_product_team(
2727
name=CPM_PRODUCT_TEAM_NO_ID["name"], keys=CPM_PRODUCT_TEAM_NO_ID["keys"]
2828
)
2929

@@ -135,7 +135,7 @@ def test_index_no_such_product_team(version, product_id):
135135
)
136136
def test_index_by_alias(version):
137137
org = Root.create_ods_organisation(ods_code=CPM_PRODUCT_TEAM_NO_ID["ods_code"])
138-
product_team = org.create_product_team_epr(
138+
product_team = org.create_product_team(
139139
name=CPM_PRODUCT_TEAM_NO_ID["name"], keys=CPM_PRODUCT_TEAM_NO_ID["keys"]
140140
)
141141

src/layers/domain/core/enum.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@ class Environment(StrEnum):
1212
REF = auto()
1313
INT = auto()
1414
PROD = auto()
15+
16+
17+
class EntityType(StrEnum):
18+
PRODUCT_TEAM = auto()
19+
PRODUCT_TEAM_ALIAS = auto()
20+
PRODUCT = auto()
Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import pytest
22
from domain.core.cpm_product import CpmProduct
33
from domain.core.product_key import ProductKey, ProductKeyType
4-
from domain.core.root import Root
54
from domain.repository.cpm_product_repository import CpmProductRepository
6-
from domain.repository.errors import AlreadyExistsError
7-
8-
from test_helpers.sample_data import CPM_PRODUCT_TEAM_NO_ID
95

106
PARTY_KEY = "ABC-123456"
117

@@ -17,32 +13,7 @@ def test__product_repository__add_key(
1713
party_key = ProductKey(key_type=ProductKeyType.PARTY_KEY, key_value=PARTY_KEY)
1814
product.add_key(**party_key.dict())
1915
repository.write(product)
20-
2116
product_by_id = repository.read(
2217
product_team_id=product.product_team_id, id=product.id
2318
)
2419
assert product_by_id.keys == [party_key]
25-
26-
27-
@pytest.mark.integration
28-
def test__product_repository__cannot_add_duplicate_key(
29-
product: CpmProduct, repository: CpmProductRepository
30-
):
31-
"""This test guards against Party Key clashes"""
32-
33-
party_key = ProductKey(key_type=ProductKeyType.PARTY_KEY, key_value=PARTY_KEY)
34-
product.add_key(**party_key.dict())
35-
repository.write(product)
36-
37-
# Create a second unrelated product
38-
org = Root.create_ods_organisation(ods_code=CPM_PRODUCT_TEAM_NO_ID["ods_code"])
39-
second_product_team = org.create_product_team(
40-
name=CPM_PRODUCT_TEAM_NO_ID["name"], keys=CPM_PRODUCT_TEAM_NO_ID["keys"]
41-
)
42-
second_product = second_product_team.create_cpm_product(
43-
name="another-cpm-product-name"
44-
)
45-
second_product.add_key(**party_key.dict())
46-
47-
with pytest.raises(AlreadyExistsError):
48-
repository.write(second_product)

src/layers/domain/repository/cpm_product_repository/v1.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
CpmProductDeletedEvent,
66
CpmProductKeyAddedEvent,
77
)
8+
from domain.core.enum import EntityType
89
from domain.core.product_key import ProductKey
910
from domain.repository.cpm_repository import Repository
1011
from domain.repository.keys import TableKey
@@ -32,27 +33,27 @@ def handle_CpmProductCreatedEvent(self, event: CpmProductCreatedEvent):
3233
parent_key_parts=(event.product_team_id,),
3334
data=asdict(event),
3435
root=True,
36+
row_type=EntityType.PRODUCT,
3537
)
3638

3739
def handle_CpmProductKeyAddedEvent(self, event: CpmProductKeyAddedEvent):
3840
# Create a copy of the Product indexed against the new key
3941
new_key = ProductKey(**event.new_key)
40-
create_transaction = self.create_index(
41-
id=new_key.key_value,
42-
parent_key_parts=(event.product_team_id,),
43-
data=asdict(event),
44-
root=False,
45-
)
46-
4742
# Update the value of "keys" on all other copies of this Device
4843
product_keys = {ProductKey(**key) for key in event.keys}
4944
product_keys_before_update = product_keys - {new_key}
5045
update_transactions = self.update_indexes(
46+
pk=TableKey.PRODUCT_TEAM.key(event.product_team_id),
5147
id=event.id,
5248
keys=product_keys_before_update,
5349
data={"keys": event.keys, "updated_on": event.updated_on},
5450
)
55-
return [create_transaction] + update_transactions
51+
return update_transactions
5652

5753
def handle_CpmProductDeletedEvent(self, event: CpmProductDeletedEvent):
58-
return self.update_indexes(id=event.id, keys=event.keys, data=asdict(event))
54+
return self.update_indexes(
55+
pk=TableKey.PRODUCT_TEAM.key(event.product_team_id),
56+
id=event.id,
57+
keys=event.keys,
58+
data=asdict(event),
59+
)

0 commit comments

Comments
 (0)