Skip to content

Commit b223bc2

Browse files
committed
fix: add first data_import_utils test and fix code
1 parent 9397989 commit b223bc2

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/osw/utils/data_import_utility.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ def get_uuid_from_object_via_type(obj: Any) -> Union[uuid_module.UUID, None]:
165165
else:
166166
type_str = str(type_)
167167
match = re.match(
168-
pattern=REGEX_PATTERN["UUID from full page title"], string=type_str
168+
pattern=REGEX_PATTERN["UUID from full page title"]["Pattern"],
169+
string=type_str,
169170
)
170171
uuid_str = match.group(3)
171172
return uuid_module.UUID(uuid_str)

tests/data_import_utility_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from uuid import UUID
2+
3+
from osw.core import OSW
4+
from osw.utils.data_import_utility import get_uuid_from_object_via_type
5+
6+
7+
def get_uuid_from_object_via_type_test():
8+
expected = UUID("2ea5b605-c91f-4e5a-9559-3dff79fdd4a5")
9+
entity = {"type": "Item:" + OSW.get_osw_id(expected)}
10+
result = get_uuid_from_object_via_type(entity)
11+
assert result == expected

0 commit comments

Comments
 (0)