mirror of https://gitlab.com/bashrc2/epicyon
Unit test for splitting collection posts
parent
101ea22e89
commit
1361610297
4
inbox.py
4
inbox.py
|
|
@ -3358,7 +3358,7 @@ def _receive_follow_request(session, session_onion, session_i2p,
|
||||||
system_language, mitm_servers)
|
system_language, mitm_servers)
|
||||||
|
|
||||||
|
|
||||||
def _split_post_collection(collection_post_json: {}) -> []:
|
def split_post_collection(collection_post_json: {}) -> []:
|
||||||
"""Splits a collection post up into separate posts
|
"""Splits a collection post up into separate posts
|
||||||
https://codeberg.org/fediverse/fep/src/branch/main/fep/1a11/fep-1a11.md
|
https://codeberg.org/fediverse/fep/src/branch/main/fep/1a11/fep-1a11.md
|
||||||
"""
|
"""
|
||||||
|
|
@ -3844,7 +3844,7 @@ def run_inbox_queue(server,
|
||||||
|
|
||||||
# if the post contains a collection of posts then split it up
|
# if the post contains a collection of posts then split it up
|
||||||
remove_queue_item = False
|
remove_queue_item = False
|
||||||
posts_list_json = _split_post_collection(queue_json['post'])
|
posts_list_json = split_post_collection(queue_json['post'])
|
||||||
for curr_post_json in posts_list_json:
|
for curr_post_json in posts_list_json:
|
||||||
|
|
||||||
if receive_undo(base_dir, curr_post_json,
|
if receive_undo(base_dir, curr_post_json,
|
||||||
|
|
|
||||||
58
tests.py
58
tests.py
|
|
@ -156,6 +156,7 @@ from media import get_attachment_media_type
|
||||||
from delete import send_delete_via_server
|
from delete import send_delete_via_server
|
||||||
from inbox import valid_inbox
|
from inbox import valid_inbox
|
||||||
from inbox import valid_inbox_filenames
|
from inbox import valid_inbox_filenames
|
||||||
|
from inbox import split_post_collection
|
||||||
from categories import guess_hashtag_category
|
from categories import guess_hashtag_category
|
||||||
from content import remove_link_trackers_from_content
|
from content import remove_link_trackers_from_content
|
||||||
from content import format_mixed_right_to_left
|
from content import format_mixed_right_to_left
|
||||||
|
|
@ -9698,6 +9699,62 @@ def _test_yggdrasil_addresses() -> None:
|
||||||
assert not is_yggdrasil_url(text)
|
assert not is_yggdrasil_url(text)
|
||||||
|
|
||||||
|
|
||||||
|
def _test_post_collection() -> None:
|
||||||
|
# https://codeberg.org/fediverse/fep/src/branch/main/fep/1a11/fep-1a11.md
|
||||||
|
print('split post collection')
|
||||||
|
post_json = {
|
||||||
|
"actor": "https://lemmings/c/gargleblaster",
|
||||||
|
"to": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
|
],
|
||||||
|
"object": {
|
||||||
|
"type": "OrderedCollection",
|
||||||
|
"id": "https://lemmings/activities/12345",
|
||||||
|
"totalItems": 3,
|
||||||
|
"orderedItems": [
|
||||||
|
{
|
||||||
|
"id": "https://lemmings/activities/like/6252183",
|
||||||
|
"actor": "https://lemmings/u/SpaceNo",
|
||||||
|
"object": "https://suckerpunch/comment/2965",
|
||||||
|
"type": "Like",
|
||||||
|
"audience": "https://lemmings/c/gargleblaster"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "https://lemmings/activities/like/3563",
|
||||||
|
"actor": "https://lemmings/u/Peter",
|
||||||
|
"object": "https://suckerpunch/comment/2965",
|
||||||
|
"type": "Like",
|
||||||
|
"audience": "https://lemmings/c/gargleblaster"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "https://lemmings/activities/like/7243",
|
||||||
|
"actor": "https://lemmings/u/Rimu",
|
||||||
|
"object": "https://suckerpunch/comment/2965",
|
||||||
|
"type": "Like",
|
||||||
|
"audience": "https://lemmings/c/gargleblaster"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"cc": [
|
||||||
|
"https://lemmings/c/gargleblaster/followers"
|
||||||
|
],
|
||||||
|
"type": "Announce",
|
||||||
|
"id": "https://lemmings/activities/announce/7643274",
|
||||||
|
"@context": []
|
||||||
|
}
|
||||||
|
posts_list = split_post_collection(post_json)
|
||||||
|
assert len(posts_list) == 3
|
||||||
|
assert posts_list[0]['type'] == "Announce"
|
||||||
|
assert posts_list[0]['object']['id'] == \
|
||||||
|
"https://lemmings/activities/like/6252183"
|
||||||
|
assert posts_list[1]['type'] == "Announce"
|
||||||
|
assert posts_list[1]['object']['id'] == \
|
||||||
|
"https://lemmings/activities/like/3563"
|
||||||
|
assert posts_list[2]['type'] == "Announce"
|
||||||
|
assert posts_list[2]['object']['id'] == \
|
||||||
|
"https://lemmings/activities/like/7243"
|
||||||
|
|
||||||
|
|
||||||
def run_all_tests():
|
def run_all_tests():
|
||||||
base_dir = os.getcwd()
|
base_dir = os.getcwd()
|
||||||
data_dir_testing(base_dir)
|
data_dir_testing(base_dir)
|
||||||
|
|
@ -9716,6 +9773,7 @@ def run_all_tests():
|
||||||
_test_checkbox_names()
|
_test_checkbox_names()
|
||||||
_test_thread_functions()
|
_test_thread_functions()
|
||||||
_test_functions()
|
_test_functions()
|
||||||
|
_test_post_collection()
|
||||||
_test_micron_blog(base_dir)
|
_test_micron_blog(base_dir)
|
||||||
_test_yggdrasil_addresses()
|
_test_yggdrasil_addresses()
|
||||||
_test_replace_gemini_links()
|
_test_replace_gemini_links()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue