Skip to content

Commit 71c516d

Browse files
eesa456axelkrastek1-nhs
authored andcommitted
NRL-820 add unit tests for when type is invalid and category does not exist for new type
1 parent f9e05db commit 71c516d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import pytest
2+
3+
from nrlf.core.constants import PointerTypes
4+
from nrlf.core.dynamodb.repository import _get_sk_ids_for_type
5+
6+
7+
def test_get_sk_ids_for_type_exception_thrown_for_invalid_type():
8+
with pytest.raises(ValueError) as error:
9+
_get_sk_ids_for_type("invalid_type")
10+
11+
assert str(error.value) == "Cannot find category for pointer type: invalid_type"
12+
13+
14+
def test_get_sk_ids_for_type_returns_type_and_category_for_every_type():
15+
for each in PointerTypes.list():
16+
category, type = _get_sk_ids_for_type(each)
17+
assert category and type
18+
19+
20+
def test_get_sk_ids_for_type_exception_thrown_if_new_type_has_no_category():
21+
pointer_types = PointerTypes.list()
22+
pointer_types.append("some_pointer_type")
23+
with pytest.raises(ValueError) as error:
24+
for each in pointer_types:
25+
category, type = _get_sk_ids_for_type(each)
26+
assert category and type
27+
28+
assert (
29+
str(error.value) == "Cannot find category for pointer type: some_pointer_type"
30+
)
31+
32+
33+
# TODO: Add unit tests for Repository Class

0 commit comments

Comments
 (0)