Unit test for getting actor from replyTo

main
Bob Mottram 2021-12-06 16:13:00 +00:00
parent 0b26fe7c99
commit 52523ad7d9
2 changed files with 16 additions and 2 deletions

View File

@ -1302,7 +1302,7 @@ def _createPostModReport(baseDir: str,
modFile.write(newPostId + '\n')
def _getActorFromInReplyTo(inReplyTo: str) -> str:
def getActorFromInReplyTo(inReplyTo: str) -> str:
"""Tries to get the replied to actor from the inReplyTo post id
Note: this will not always be successful for some instance types
"""
@ -1462,7 +1462,7 @@ def _createPostBase(baseDir: str,
if inReplyTo and isPublic:
# If this is a public post then get the actor being
# replied to end ensure that it is within the CC list
replyActor = _getActorFromInReplyTo(inReplyTo)
replyActor = getActorFromInReplyTo(inReplyTo)
if replyActor:
if replyActor not in toCC:
toCC.append(replyActor)

View File

@ -36,6 +36,7 @@ from threads import threadWithTrace
from daemon import runDaemon
from session import createSession
from session import getJson
from posts import getActorFromInReplyTo
from posts import regenerateIndexForBox
from posts import removePostInteractions
from posts import getMentionedPeople
@ -6013,6 +6014,18 @@ def _testHttpsigBaseNew(withDigest: bool, baseDir: str,
shutil.rmtree(path, ignore_errors=False, onerror=None)
def _testGetActorFromInReplyTo() -> None:
print('testGetActorFromInReplyTo')
inReplyTo = \
'https://fosstodon.org/users/bashrc/statuses/107400700612621140'
replyActor = getActorFromInReplyTo(inReplyTo)
assert replyActor == 'https://fosstodon.org/users/bashrc'
inReplyTo = 'https://fosstodon.org/activity/107400700612621140'
replyActor = getActorFromInReplyTo(inReplyTo)
assert replyActor is None
def runAllTests():
baseDir = os.getcwd()
print('Running tests...')
@ -6020,6 +6033,7 @@ def runAllTests():
_translateOntology(baseDir)
_testGetPriceFromString()
_testFunctions()
_testGetActorFromInReplyTo()
_testValidEmojiContent()
_testAddCWfromLists(baseDir)
_testWordsSimilarity()