Test for actor parsing

master
Bob Mottram 2019-08-21 17:35:46 +01:00
parent 58f78f1751
commit 0bfb3b578e
2 changed files with 27 additions and 2 deletions

View File

@ -62,14 +62,14 @@ The following are considered antifeatures of other social network systems, since
On Arch/Parabola: On Arch/Parabola:
``` bash ``` bash
sudo pacman -S tor python-pip python-pysocks python-pycryptodome python-beautifulsoup4 imagemagick python-pillow python-numpy sudo pacman -S tor python-pip python-pysocks python-pycryptodome python-beautifulsoup4 imagemagick python-pillow python-numpy python-dateutil
sudo pip install commentjson sudo pip install commentjson
``` ```
Or on Debian: Or on Debian:
``` bash ``` bash
sudo apt-get -y install tor python3-pip python3-socks imagemagick python3-numpy python3-setuptools python3-crypto python3-pil.imagetk sudo apt-get -y install tor python3-pip python3-socks imagemagick python3-numpy python3-setuptools python3-crypto python3-dateutil python3-pil.imagetk
sudo pip3 install commentjson beautifulsoup4 pycryptodome sudo pip3 install commentjson beautifulsoup4 pycryptodome
``` ```

View File

@ -38,6 +38,8 @@ from follow import clearFollowers
from follow import sendFollowRequestViaServer from follow import sendFollowRequestViaServer
from follow import sendUnfollowRequestViaServer from follow import sendUnfollowRequestViaServer
from utils import followPerson from utils import followPerson
from utils import getNicknameFromActor
from utils import getDomainFromActor
from follow import followerOfPerson from follow import followerOfPerson
from follow import unfollowPerson from follow import unfollowPerson
from follow import unfollowerOfPerson from follow import unfollowerOfPerson
@ -1340,8 +1342,31 @@ def testClientToServer():
#shutil.rmtree(aliceDir) #shutil.rmtree(aliceDir)
#shutil.rmtree(bobDir) #shutil.rmtree(bobDir)
def testActorParsing():
print('testActorParsing')
actor='https://mydomain:72/users/mynick'
domain,port=getDomainFromActor(actor)
assert domain=='mydomain'
assert port==72
nickname=getNicknameFromActor(actor)
assert nickname=='mynick'
actor='https://randomain/users/rando'
domain,port=getDomainFromActor(actor)
assert domain=='randomain'
nickname=getNicknameFromActor(actor)
assert nickname=='rando'
actor='https://otherdomain:49/@othernick'
domain,port=getDomainFromActor(actor)
assert domain=='otherdomain'
assert port==49
nickname=getNicknameFromActor(actor)
assert nickname=='othernick'
def runAllTests(): def runAllTests():
print('Running tests...') print('Running tests...')
testActorParsing()
testHttpsig() testHttpsig()
testCache() testCache()
testThreads() testThreads()