Fix unit test for like

main2
Bob Mottram 2019-10-19 19:08:47 +01:00
parent 255a32c0dc
commit 236aef17ba
3 changed files with 19 additions and 24 deletions

View File

@ -4826,7 +4826,7 @@ def runDaemon(projectVersion, \
httpd.ocapAlways,maxReplies, \ httpd.ocapAlways,maxReplies, \
domainMaxPostsPerDay,accountMaxPostsPerDay, \ domainMaxPostsPerDay,accountMaxPostsPerDay, \
allowDeletion,debug,maxMentions,httpd.translate, \ allowDeletion,debug,maxMentions,httpd.translate, \
httpd.acceptedCaps),daemon=True) unitTest,httpd.acceptedCaps),daemon=True)
if not unitTest: if not unitTest:
httpd.thrWatchdog= \ httpd.thrWatchdog= \
threadWithTrace(target=runInboxQueueWatchdog, \ threadWithTrace(target=runInboxQueueWatchdog, \

View File

@ -1513,7 +1513,8 @@ def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \
acceptedCaps: [], \ acceptedCaps: [], \
queueFilename :str,destinationFilename :str, \ queueFilename :str,destinationFilename :str, \
maxReplies: int,allowDeletion: bool, \ maxReplies: int,allowDeletion: bool, \
maxMentions: int,translate: {}) -> bool: maxMentions: int,translate: {}, \
unitTest: bool) -> bool:
""" Anything which needs to be done after capabilities checks have passed """ Anything which needs to be done after capabilities checks have passed
""" """
actor=keyId actor=keyId
@ -1640,14 +1641,16 @@ def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \
if postSavedToFile: if postSavedToFile:
inboxUpdateCalendar(baseDir,handle,postJsonObject) inboxUpdateCalendar(baseDir,handle,postJsonObject)
if debug:
print('DEBUG: saving inbox post as html to cache') if not unitTest:
inboxStorePostToHtmlCache(translate,baseDir,httpPrefix, \ if debug:
session,cachedWebfingers,personCache, \ print('DEBUG: saving inbox post as html to cache')
handle.split('@')[0],domain,port, \ inboxStorePostToHtmlCache(translate,baseDir,httpPrefix, \
postJsonObject,allowDeletion) session,cachedWebfingers,personCache, \
if debug: handle.split('@')[0],domain,port, \
print('DEBUG: saved inbox post as html to cache') postJsonObject,allowDeletion)
if debug:
print('DEBUG: saved inbox post as html to cache')
# send the post out to group members # send the post out to group members
if isGroup: if isGroup:
@ -1697,7 +1700,7 @@ def runInboxQueue(projectVersion: str, \
ocapAlways: bool,maxReplies: int, \ ocapAlways: bool,maxReplies: int, \
domainMaxPostsPerDay: int,accountMaxPostsPerDay: int, \ domainMaxPostsPerDay: int,accountMaxPostsPerDay: int, \
allowDeletion: bool,debug: bool,maxMentions: int, \ allowDeletion: bool,debug: bool,maxMentions: int, \
translate: {}, \ translate: {},unitTest: bool, \
acceptedCaps=["inbox:write","objects:read"]) -> None: acceptedCaps=["inbox:write","objects:read"]) -> None:
"""Processes received items and moves them to """Processes received items and moves them to
the appropriate directories the appropriate directories
@ -2057,7 +2060,7 @@ def runInboxQueue(projectVersion: str, \
debug,acceptedCaps, \ debug,acceptedCaps, \
queueFilename,destination, \ queueFilename,destination, \
maxReplies,allowDeletion, \ maxReplies,allowDeletion, \
maxMentions,translate) maxMentions,translate,unitTest)
else: else:
if debug: if debug:
print('DEBUG: object capabilities check has failed') print('DEBUG: object capabilities check has failed')
@ -2075,7 +2078,7 @@ def runInboxQueue(projectVersion: str, \
debug,acceptedCaps, \ debug,acceptedCaps, \
queueFilename,destination, \ queueFilename,destination, \
maxReplies,allowDeletion, \ maxReplies,allowDeletion, \
maxMentions,translate) maxMentions,translate,unitTest)
if debug: if debug:
pprint(queueJson['post']) pprint(queueJson['post'])
print('No capability list within post') print('No capability list within post')

View File

@ -44,17 +44,9 @@ class threadWithTrace(threading.Thread):
self.isStarted=True self.isStarted=True
def __run(self): def __run(self):
tries=0 sys.settrace(self.globaltrace)
while tries<3: self.__run_backup()
try: self.run = self.__run_backup
sys.settrace(self.globaltrace)
self.__run_backup()
self.run = self.__run_backup
break
except Exception as e:
print('ERROR: threads.py/__run failed - '+str(e))
time.sleep(1)
tries+=1
def globaltrace(self, frame, event, arg): def globaltrace(self, frame, event, arg):
if event == 'call': if event == 'call':