From 0bfb3b578e3ab8f672531706513aa2897e441b80 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 21 Aug 2019 17:35:46 +0100 Subject: [PATCH] Test for actor parsing --- README.md | 4 ++-- tests.py | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f61205ad..af4934be 100644 --- a/README.md +++ b/README.md @@ -62,14 +62,14 @@ The following are considered antifeatures of other social network systems, since On Arch/Parabola: ``` 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 ``` Or on Debian: ``` 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 ``` diff --git a/tests.py b/tests.py index d6bf9034..a468bd0e 100644 --- a/tests.py +++ b/tests.py @@ -38,6 +38,8 @@ from follow import clearFollowers from follow import sendFollowRequestViaServer from follow import sendUnfollowRequestViaServer from utils import followPerson +from utils import getNicknameFromActor +from utils import getDomainFromActor from follow import followerOfPerson from follow import unfollowPerson from follow import unfollowerOfPerson @@ -1340,8 +1342,31 @@ def testClientToServer(): #shutil.rmtree(aliceDir) #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(): print('Running tests...') + testActorParsing() testHttpsig() testCache() testThreads()