From 236aef17ba88d6b3addc6bcd8730c24f67404784 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 19 Oct 2019 19:08:47 +0100 Subject: [PATCH] Fix unit test for like --- daemon.py | 2 +- inbox.py | 27 +++++++++++++++------------ threads.py | 14 +++----------- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/daemon.py b/daemon.py index 1abc4f362..d680524c8 100644 --- a/daemon.py +++ b/daemon.py @@ -4826,7 +4826,7 @@ def runDaemon(projectVersion, \ httpd.ocapAlways,maxReplies, \ domainMaxPostsPerDay,accountMaxPostsPerDay, \ allowDeletion,debug,maxMentions,httpd.translate, \ - httpd.acceptedCaps),daemon=True) + unitTest,httpd.acceptedCaps),daemon=True) if not unitTest: httpd.thrWatchdog= \ threadWithTrace(target=runInboxQueueWatchdog, \ diff --git a/inbox.py b/inbox.py index 399712b2e..11ac0a265 100644 --- a/inbox.py +++ b/inbox.py @@ -1513,7 +1513,8 @@ def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \ acceptedCaps: [], \ queueFilename :str,destinationFilename :str, \ 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 """ actor=keyId @@ -1640,14 +1641,16 @@ def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \ if postSavedToFile: inboxUpdateCalendar(baseDir,handle,postJsonObject) - if debug: - print('DEBUG: saving inbox post as html to cache') - inboxStorePostToHtmlCache(translate,baseDir,httpPrefix, \ - session,cachedWebfingers,personCache, \ - handle.split('@')[0],domain,port, \ - postJsonObject,allowDeletion) - if debug: - print('DEBUG: saved inbox post as html to cache') + + if not unitTest: + if debug: + print('DEBUG: saving inbox post as html to cache') + inboxStorePostToHtmlCache(translate,baseDir,httpPrefix, \ + session,cachedWebfingers,personCache, \ + handle.split('@')[0],domain,port, \ + postJsonObject,allowDeletion) + if debug: + print('DEBUG: saved inbox post as html to cache') # send the post out to group members if isGroup: @@ -1697,7 +1700,7 @@ def runInboxQueue(projectVersion: str, \ ocapAlways: bool,maxReplies: int, \ domainMaxPostsPerDay: int,accountMaxPostsPerDay: int, \ allowDeletion: bool,debug: bool,maxMentions: int, \ - translate: {}, \ + translate: {},unitTest: bool, \ acceptedCaps=["inbox:write","objects:read"]) -> None: """Processes received items and moves them to the appropriate directories @@ -2057,7 +2060,7 @@ def runInboxQueue(projectVersion: str, \ debug,acceptedCaps, \ queueFilename,destination, \ maxReplies,allowDeletion, \ - maxMentions,translate) + maxMentions,translate,unitTest) else: if debug: print('DEBUG: object capabilities check has failed') @@ -2075,7 +2078,7 @@ def runInboxQueue(projectVersion: str, \ debug,acceptedCaps, \ queueFilename,destination, \ maxReplies,allowDeletion, \ - maxMentions,translate) + maxMentions,translate,unitTest) if debug: pprint(queueJson['post']) print('No capability list within post') diff --git a/threads.py b/threads.py index c0dc7066e..9f59095bc 100644 --- a/threads.py +++ b/threads.py @@ -44,17 +44,9 @@ class threadWithTrace(threading.Thread): self.isStarted=True def __run(self): - tries=0 - while tries<3: - try: - 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 + sys.settrace(self.globaltrace) + self.__run_backup() + self.run = self.__run_backup def globaltrace(self, frame, event, arg): if event == 'call':