Check that imports are correct

main
Bob Mottram 2020-12-22 13:57:24 +00:00
parent 59357c0c4f
commit 0cf0841402
4 changed files with 39 additions and 28 deletions

View File

@ -87,7 +87,7 @@ from inbox import populateReplies
from inbox import getPersonPubKey
from follow import getFollowingFeed
from follow import sendFollowRequest
from follow import unfollowPerson
from follow import unfollowAccount
from follow import createInitialLastSeen
from auth import authorize
from auth import createPassword
@ -2115,9 +2115,9 @@ class PubServer(BaseHTTPRequestHandler):
}
pathUsersSection = path.split('/users/')[1]
self.postToNickname = pathUsersSection.split('/')[0]
unfollowPerson(self.server.baseDir, self.postToNickname,
self.server.domain,
followingNickname, followingDomainFull)
unfollowAccount(self.server.baseDir, self.postToNickname,
self.server.domain,
followingNickname, followingDomainFull)
self._postToOutboxThread(unfollowJson)
if callingDomain.endswith('.onion') and onionDomain:

View File

@ -212,10 +212,10 @@ def isFollowerOfPerson(baseDir: str, nickname: str, domain: str,
return alreadyFollowing
def unfollowPerson(baseDir: str, nickname: str, domain: str,
followNickname: str, followDomain: str,
followFile='following.txt',
debug=False) -> bool:
def unfollowAccount(baseDir: str, nickname: str, domain: str,
followNickname: str, followDomain: str,
followFile='following.txt',
debug=False) -> bool:
"""Removes a person to the follow list
"""
if ':' in domain:
@ -261,14 +261,14 @@ def unfollowPerson(baseDir: str, nickname: str, domain: str,
return True
def unfollowerOfPerson(baseDir: str, nickname: str, domain: str,
followerNickname: str, followerDomain: str,
debug=False) -> bool:
def unfollowerOfAccount(baseDir: str, nickname: str, domain: str,
followerNickname: str, followerDomain: str,
debug=False) -> bool:
"""Remove a follower of a person
"""
return unfollowPerson(baseDir, nickname, domain,
followerNickname, followerDomain,
'followers.txt', debug)
return unfollowAccount(baseDir, nickname, domain,
followerNickname, followerDomain,
'followers.txt', debug)
def clearFollows(baseDir: str, nickname: str, domain: str,
@ -1208,8 +1208,8 @@ def outboxUndoFollow(baseDir: str, messageJson: {}, debug: bool) -> None:
getDomainFromActor(messageJson['object']['object'])
domainFollowingFull = getFullDomain(domainFollowing, portFollowing)
if unfollowPerson(baseDir, nicknameFollower, domainFollowerFull,
nicknameFollowing, domainFollowingFull):
if unfollowAccount(baseDir, nicknameFollower, domainFollowerFull,
nicknameFollowing, domainFollowingFull):
if debug:
print('DEBUG: ' + nicknameFollower + ' unfollowed ' +
nicknameFollowing + '@' + domainFollowingFull)

View File

@ -39,7 +39,7 @@ from session import createSession
from session import getJson
from follow import receiveFollowRequest
from follow import getFollowersOfActor
from follow import unfollowerOfPerson
from follow import unfollowerOfAccount
from pprint import pprint
from cache import getPersonFromCache
from cache import storePersonInCache
@ -49,8 +49,8 @@ from bookmarks import undoBookmarksCollectionEntry
from blocking import isBlocked
from blocking import isBlockedDomain
from filters import isFiltered
from announce import updateAnnounceCollection
from announce import undoAnnounceCollectionEntry
from utils import updateAnnounceCollection
from utils import undoAnnounceCollectionEntry
from httpsig import messageContentDigest
from posts import validContentWarning
from posts import downloadAnnounce
@ -637,10 +637,10 @@ def receiveUndoFollow(session, baseDir: str, httpPrefix: str,
getDomainFromActor(messageJson['object']['object'])
domainFollowingFull = getFullDomain(domainFollowing, portFollowing)
if unfollowerOfPerson(baseDir,
nicknameFollowing, domainFollowingFull,
nicknameFollower, domainFollowerFull,
debug):
if unfollowerOfAccount(baseDir,
nicknameFollowing, domainFollowingFull,
nicknameFollower, domainFollowerFull,
debug):
print(nicknameFollowing + '@' + domainFollowingFull + ': '
'Follower ' + nicknameFollower + '@' + domainFollowerFull +
' was removed')

View File

@ -49,8 +49,8 @@ from utils import getStatusNumber
from utils import getFollowersOfPerson
from utils import removeHtml
from follow import followerOfPerson
from follow import unfollowPerson
from follow import unfollowerOfPerson
from follow import unfollowAccount
from follow import unfollowerOfAccount
from follow import sendFollowRequest
from person import createPerson
from person import setDisplayNickname
@ -73,7 +73,7 @@ from delete import sendDeleteViaServer
from inbox import jsonPostAllowsComments
from inbox import validInbox
from inbox import validInboxFilenames
from inbox import guessHashtagCategory
from categories import guessHashtagCategory
from content import htmlReplaceEmailQuote
from content import htmlReplaceQuoteMarks
from content import dangerousMarkup
@ -978,7 +978,7 @@ def testNoOfFollowersOnDomain():
noOfFollowersOnDomain(baseDir, nickname + '@' + domain, otherdomain)
assert followersOnOtherDomain == 3
unfollowerOfPerson(baseDir, nickname, domain, 'sausagedog', otherdomain)
unfollowerOfAccount(baseDir, nickname, domain, 'sausagedog', otherdomain)
followersOnOtherDomain = \
noOfFollowersOnDomain(baseDir, nickname + '@' + domain, otherdomain)
assert followersOnOtherDomain == 2
@ -1074,7 +1074,7 @@ def testFollows():
assert(False)
assert(domainFound)
unfollowPerson(baseDir, nickname, domain, 'batman', 'mesh.com')
unfollowAccount(baseDir, nickname, domain, 'batman', 'mesh.com')
domainFound = False
for followingDomain in f:
@ -2614,6 +2614,9 @@ def testFunctions():
'E2EEremoveDevice',
'setOrganizationScheme'
]
excludeImports = [
'link'
]
# check that functions are called somewhere
for name, properties in functionProperties.items():
if name in exclusions:
@ -2623,6 +2626,14 @@ def testFunctions():
' in module ' + properties['module'] +
' is not called anywhere')
assert properties['calledInModule']
if name not in excludeImports:
for modName in properties['calledInModule']:
if modName == properties['module']:
continue
importStr = 'from ' + properties['module'] + ' import ' + name
if importStr not in open(modName + '.py').read():
print(importStr + ' not found in ' + modName + '.py')
assert False
print('Function: ' + name + '')
# print(str(function))
# print(str(functionProperties))