Test the utils
Comment create wrapper Test comment wrapper
This commit is contained in:
parent
010d54bc87
commit
fb1953e953
11 changed files with 107 additions and 6 deletions
|
|
@ -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
|
||||
|
|
@ -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
9
utils/get_post_pksk.py
Normal 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}"
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue