forked from indymedia/epicyon
Test for follow capabilities creation
parent
994ce34a76
commit
3addf30a9b
|
@ -138,11 +138,14 @@ def acceptFollow(baseDir: str,domain : str,messageJson: {}, \
|
|||
return
|
||||
|
||||
# are capabilities attached? If so then store them
|
||||
if messageJson['object'].get('capabilities'):
|
||||
if isinstance(messageJson['object']['capabilities'], dict):
|
||||
if messageJson.get('capabilities'):
|
||||
if isinstance(messageJson['capabilities'], dict):
|
||||
acceptedDomainFull=acceptedDomain
|
||||
if acceptedPort:
|
||||
acceptedDomainFull=acceptedDomain+':'+str(acceptedPort)
|
||||
capabilitiesGrantedSave(baseDir, \
|
||||
followedNickname,followedDomain, \
|
||||
messageJson['object']['capabilities'])
|
||||
nickname,acceptedDomainFull, \
|
||||
messageJson['capabilities'])
|
||||
|
||||
if followPerson(baseDir, \
|
||||
nickname,acceptedDomain, \
|
||||
|
|
|
@ -91,7 +91,8 @@ def capabilitiesGrantedSave(baseDir :str,nickname :str,domain :str,ocap: {}) ->
|
|||
"""
|
||||
if not ocap.get('actor'):
|
||||
return False
|
||||
ocapFilename=getOcapFilename(baseDir,nickname,fullDomain,ocap['actor'],'granted')
|
||||
capabilitiesMakeDirs(baseDir)
|
||||
ocapFilename=getOcapFilename(baseDir,nickname,domain,ocap['actor'],'granted')
|
||||
with open(ocapFilename, 'w') as fp:
|
||||
commentjson.dump(ocap, fp, indent=4, sort_keys=False)
|
||||
return True
|
||||
|
|
6
tests.py
6
tests.py
|
@ -314,7 +314,8 @@ def testFollowBetweenServers():
|
|||
if os.path.isfile(bobDir+'/accounts/bob@'+bobDomain+'/followers.txt'):
|
||||
if os.path.isfile(aliceDir+'/accounts/alice@'+aliceDomain+'/following.txt'):
|
||||
if os.path.isfile(bobDir+'/ocap/accept/'+bobDomain+':'+str(bobPort)+':bob:'+httpPrefix+':##'+aliceDomain+':'+str(alicePort)+'#users#alice.json'):
|
||||
break
|
||||
if os.path.isfile(aliceDir+'/ocap/granted/'+aliceDomain+':'+str(alicePort)+':alice:'+httpPrefix+':##'+bobDomain+':'+str(bobPort)+'#users#bob.json'):
|
||||
break
|
||||
time.sleep(1)
|
||||
|
||||
# stop the servers
|
||||
|
@ -327,11 +328,12 @@ def testFollowBetweenServers():
|
|||
assert thrBob.isAlive()==False
|
||||
|
||||
assert os.path.isfile(bobDir+'/ocap/accept/'+bobDomain+':'+str(bobPort)+':bob:'+httpPrefix+':##'+aliceDomain+':'+str(alicePort)+'#users#alice.json')
|
||||
assert os.path.isfile(aliceDir+'/ocap/granted/'+aliceDomain+':'+str(alicePort)+':alice:'+httpPrefix+':##'+bobDomain+':'+str(bobPort)+'#users#bob.json')
|
||||
assert 'alice@'+aliceDomain in open(bobDir+'/accounts/bob@'+bobDomain+'/followers.txt').read()
|
||||
assert 'bob@'+bobDomain in open(aliceDir+'/accounts/alice@'+aliceDomain+'/following.txt').read()
|
||||
|
||||
os.chdir(baseDir)
|
||||
#shutil.rmtree(baseDir+'/.tests')
|
||||
shutil.rmtree(baseDir+'/.tests')
|
||||
|
||||
def testFollowersOfPerson():
|
||||
print('testFollowersOfPerson')
|
||||
|
|
Loading…
Reference in New Issue