Skip to content

Commit 9d4eb59

Browse files
committed
Add a test to confirm generated ID doesn't exist in Generated list
1 parent 7584fee commit 9d4eb59

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ boto3-stubs = { extras = [
5656
], version = "^1.34.37" }
5757
pytest-timeout = "^2.2.0"
5858
lz4 = "^4.3.3"
59+
pytest-repeat = "^0.9.3"
5960

6061
[tool.poetry.group.local]
6162
optional = true

src/layers/domain/core/cpm_system_id/tests/test_cpm_system_id_v1.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
1+
import os
2+
from pathlib import Path
3+
14
import pytest
25
from domain.core.cpm_system_id import AsidId, PartyKeyId, ProductId
6+
from event.json import json_load
7+
8+
PATH_TO_CPM_SYSTEM_IDS = Path(__file__).parent.parent
9+
PRODUCT_IDS_GENERATED_FILE = f"{PATH_TO_CPM_SYSTEM_IDS}/generated_ids/product_ids.json"
10+
generated_product_ids = set()
11+
12+
13+
@pytest.fixture(scope="module", autouse=True)
14+
def _get_generated_ids():
15+
global generated_product_ids
16+
if os.path.exists(PRODUCT_IDS_GENERATED_FILE):
17+
with open(PRODUCT_IDS_GENERATED_FILE, "r") as file:
18+
generated_product_ids = set(json_load(file))
319

420

521
def test_party_key_generator_format_key():
@@ -71,9 +87,11 @@ def test_asid_generator_increment_number():
7187
assert generator.id == "223456789013"
7288

7389

90+
@pytest.mark.repeat(50)
7491
def test_product_id_generator_format_key():
7592
generator = ProductId.create()
7693
assert generator.id is not None
94+
assert generator.id not in generated_product_ids
7795

7896

7997
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)