mirror of https://gitlab.com/bashrc2/epicyon
Extra test for last published
parent
4602c7f7bc
commit
84469d16f0
28
posts.py
28
posts.py
|
@ -937,6 +937,23 @@ def delete_all_posts(base_dir: str,
|
|||
print('ERROR: delete_all_posts ' + str(ex))
|
||||
|
||||
|
||||
def _save_last_published(base_dir: str, nickname: str, domain: str,
|
||||
published: str) -> None:
|
||||
"""Saves the last published date for the outbox
|
||||
"""
|
||||
if not published:
|
||||
return
|
||||
|
||||
published_filename = \
|
||||
acct_dir(base_dir, nickname, domain) + '/.last_published'
|
||||
try:
|
||||
with open(published_filename, 'w+', encoding='utf-8') as fp_last:
|
||||
fp_last.write(published)
|
||||
except OSError:
|
||||
print('EX: unable to save last published time ' +
|
||||
published_filename)
|
||||
|
||||
|
||||
def save_post_to_box(base_dir: str, http_prefix: str, post_id: str,
|
||||
nickname: str, domain: str, post_json_object: {},
|
||||
boxname: str) -> str:
|
||||
|
@ -970,16 +987,7 @@ def save_post_to_box(base_dir: str, http_prefix: str, post_id: str,
|
|||
# if this is an outbox post with a duplicate in the inbox then save to both
|
||||
# This happens for edited posts
|
||||
if '/outbox/' in filename:
|
||||
if published:
|
||||
published_filename = \
|
||||
acct_dir(base_dir, nickname, domain) + '/.last_published'
|
||||
try:
|
||||
with open(published_filename, 'w+',
|
||||
encoding='utf-8') as fp_last:
|
||||
fp_last.write(published)
|
||||
except OSError:
|
||||
print('EX: unable to save last published time ' +
|
||||
published_filename)
|
||||
_save_last_published(base_dir, nickname, domain, published)
|
||||
|
||||
inbox_filename = filename.replace('/outbox/', '/inbox/')
|
||||
if os.path.isfile(inbox_filename):
|
||||
|
|
5
tests.py
5
tests.py
|
@ -1364,6 +1364,9 @@ def test_post_message_between_servers(base_dir: str) -> None:
|
|||
is_article = False
|
||||
city = 'London, England'
|
||||
# nothing in Alice's outbox
|
||||
last_pub_filename = \
|
||||
alice_dir + '/accounts/alice@' + alice_domain + '/.last_published'
|
||||
assert not os.path.isfile(last_pub_filename)
|
||||
outbox_path = alice_dir + '/accounts/alice@' + alice_domain + '/outbox'
|
||||
assert len([name for name in os.listdir(outbox_path)
|
||||
if os.path.isfile(os.path.join(outbox_path, name))]) == 0
|
||||
|
@ -1412,6 +1415,8 @@ def test_post_message_between_servers(base_dir: str) -> None:
|
|||
break
|
||||
time.sleep(1)
|
||||
|
||||
assert os.path.isfile(last_pub_filename)
|
||||
|
||||
# check that a news account exists
|
||||
news_actor_dir = alice_dir + '/accounts/news@' + alice_domain
|
||||
print("news_actor_dir: " + news_actor_dir)
|
||||
|
|
Loading…
Reference in New Issue