Test the utils

Comment create wrapper
Test comment wrapper
This commit is contained in:
simonwt 2026-04-01 23:00:42 +01:00
parent 010d54bc87
commit fb1953e953
11 changed files with 107 additions and 6 deletions

View file

@ -1 +1,2 @@
from .get_parent_pksk_from_path import get_parent_pksk_from_path
from .get_parent_pksk_from_path import get_parent_pksk_from_path
from .get_post_pksk import get_post_pksk

View file

@ -3,12 +3,13 @@ def get_parent_pksk_from_path(parent_path):
return 'maintrunk#maintrunk'
entity, slug = parent_path.strip('/').split('/')
if entity == 'branch':
entity = 'subwiki'
elif entity != 'user':
elif entity == 'user':
entity = 'userprofile'
if entity not in ['userprofile', 'subwiki']:
raise ValueError(f"Invalid parent entity: {entity}. Must be 'userprofile' or 'branch'.")
raise ValueError(f"Invalid parent entity: {entity}. Must be 'userprofile' or 'subwiki'.")
return f"{entity}#{slug}"

9
utils/get_post_pksk.py Normal file
View file

@ -0,0 +1,9 @@
def get_post_pksk(parent_pksk, post_url):
post_slug = post_url.strip('/post/')
return {
"pk": parent_pksk,
"sk": f"post#{post_slug}"
}