forked from indymedia/epicyon
Test for cache
parent
e485010e4e
commit
687c4378da
12
cache.py
12
cache.py
|
@ -33,7 +33,7 @@ def getPersonFromCache(personUrl: str):
|
|||
if personCache.get(personUrl):
|
||||
# how old is the cached data?
|
||||
currTime=datetime.datetime.utcnow()
|
||||
cacheTime=datetime.strptime(personCache[personUrl]['timestamp'].replace('T',' '))
|
||||
cacheTime=datetime.datetime.strptime(personCache[personUrl]['timestamp'],"%Y-%m-%dT%H:%M:%SZ")
|
||||
daysSinceCached=(currTime - cacheTime).days
|
||||
# return cached value if it has not expired
|
||||
if daysSinceCached <= 2:
|
||||
|
@ -46,3 +46,13 @@ def getWebfingerFromCache(handle: str):
|
|||
if cachedWebfingers.get(handle):
|
||||
return cachedWebfingers[handle]
|
||||
return None
|
||||
|
||||
def testCache():
|
||||
print('testCache')
|
||||
personUrl="cat@cardboard.box"
|
||||
personJson={ "id": 123456, "test": "This is a test" }
|
||||
storePersonInCache(personUrl,personJson)
|
||||
result=getPersonFromCache(personUrl)
|
||||
assert result['id']==123456
|
||||
assert result['test']=='This is a test'
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import cgi
|
|||
from pprint import pprint
|
||||
from session import createSession
|
||||
from httpsig import testHttpsig
|
||||
from cache import testCache
|
||||
from webfinger import webfingerMeta
|
||||
from webfinger import webfingerLookup
|
||||
from person import personLookup
|
||||
|
@ -218,6 +219,7 @@ def runDaemon(domain: str,port=80,fedList=[],useTor=False) -> None:
|
|||
|
||||
print('Running tests...')
|
||||
testHttpsig()
|
||||
testCache()
|
||||
print('Tests succeeded\n')
|
||||
|
||||
serverAddress = ('', port)
|
||||
|
|
|
@ -32,10 +32,10 @@ from follow import followerOfPerson
|
|||
from follow import unfollowPerson
|
||||
from follow import unfollowerOfPerson
|
||||
|
||||
federationList=['mastodon.social','wild.com','trees.com']
|
||||
federationList=['mastodon.social','wild.com','trees.com','127.0.0.1']
|
||||
username='testuser'
|
||||
#domain=socket.gethostname()
|
||||
domain='mydomain.com'
|
||||
domain='127.0.0.1'
|
||||
port=6227
|
||||
https=True
|
||||
useTor=False
|
||||
|
|
Loading…
Reference in New Issue