mirror of https://gitlab.com/bashrc2/epicyon
Unit test for getting actor from replyTo
parent
0b26fe7c99
commit
52523ad7d9
4
posts.py
4
posts.py
|
@ -1302,7 +1302,7 @@ def _createPostModReport(baseDir: str,
|
||||||
modFile.write(newPostId + '\n')
|
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
|
"""Tries to get the replied to actor from the inReplyTo post id
|
||||||
Note: this will not always be successful for some instance types
|
Note: this will not always be successful for some instance types
|
||||||
"""
|
"""
|
||||||
|
@ -1462,7 +1462,7 @@ def _createPostBase(baseDir: str,
|
||||||
if inReplyTo and isPublic:
|
if inReplyTo and isPublic:
|
||||||
# If this is a public post then get the actor being
|
# If this is a public post then get the actor being
|
||||||
# replied to end ensure that it is within the CC list
|
# replied to end ensure that it is within the CC list
|
||||||
replyActor = _getActorFromInReplyTo(inReplyTo)
|
replyActor = getActorFromInReplyTo(inReplyTo)
|
||||||
if replyActor:
|
if replyActor:
|
||||||
if replyActor not in toCC:
|
if replyActor not in toCC:
|
||||||
toCC.append(replyActor)
|
toCC.append(replyActor)
|
||||||
|
|
14
tests.py
14
tests.py
|
@ -36,6 +36,7 @@ from threads import threadWithTrace
|
||||||
from daemon import runDaemon
|
from daemon import runDaemon
|
||||||
from session import createSession
|
from session import createSession
|
||||||
from session import getJson
|
from session import getJson
|
||||||
|
from posts import getActorFromInReplyTo
|
||||||
from posts import regenerateIndexForBox
|
from posts import regenerateIndexForBox
|
||||||
from posts import removePostInteractions
|
from posts import removePostInteractions
|
||||||
from posts import getMentionedPeople
|
from posts import getMentionedPeople
|
||||||
|
@ -6013,6 +6014,18 @@ def _testHttpsigBaseNew(withDigest: bool, baseDir: str,
|
||||||
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
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():
|
def runAllTests():
|
||||||
baseDir = os.getcwd()
|
baseDir = os.getcwd()
|
||||||
print('Running tests...')
|
print('Running tests...')
|
||||||
|
@ -6020,6 +6033,7 @@ def runAllTests():
|
||||||
_translateOntology(baseDir)
|
_translateOntology(baseDir)
|
||||||
_testGetPriceFromString()
|
_testGetPriceFromString()
|
||||||
_testFunctions()
|
_testFunctions()
|
||||||
|
_testGetActorFromInReplyTo()
|
||||||
_testValidEmojiContent()
|
_testValidEmojiContent()
|
||||||
_testAddCWfromLists(baseDir)
|
_testAddCWfromLists(baseDir)
|
||||||
_testWordsSimilarity()
|
_testWordsSimilarity()
|
||||||
|
|
Loading…
Reference in New Issue