From 9003ae187d54d5a65c35731c97df5c69ed3b0045 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 1 Jul 2021 21:41:17 +0100 Subject: [PATCH] Fix public post tests --- epicyon.py | 56 ++++++++++++++++++++----- posts.py | 12 +++--- tests.py | 117 ++++++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 156 insertions(+), 29 deletions(-) diff --git a/epicyon.py b/epicyon.py index 226dee02a..3d6fe6d1b 100644 --- a/epicyon.py +++ b/epicyon.py @@ -2310,6 +2310,14 @@ if args.testdata: testMediaType = None testImageDescription = None testCity = 'London, England' + testInReplyTo = None + testInReplyToAtomUri = None + testSubject = None + testSchedulePost = False + testEventDate = None + testEventTime = None + testLocation = None + testIsArticle = False createPublicPost(baseDir, nickname, domain, port, httpPrefix, "like this is totally just a #test man", @@ -2318,7 +2326,11 @@ if args.testdata: testC2S, testCommentsEnabled, testAttachImageFilename, - testMediaType, testImageDescription, testCity) + testMediaType, testImageDescription, testCity, + testInReplyTo, testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) createPublicPost(baseDir, nickname, domain, port, httpPrefix, "Zoiks!!!", testFollowersOnly, @@ -2326,7 +2338,11 @@ if args.testdata: testC2S, testCommentsEnabled, testAttachImageFilename, - testMediaType, testImageDescription, testCity) + testMediaType, testImageDescription, testCity, + testInReplyTo, testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) createPublicPost(baseDir, nickname, domain, port, httpPrefix, "Hey scoob we need like a hundred more #milkshakes", testFollowersOnly, @@ -2334,7 +2350,11 @@ if args.testdata: testC2S, testCommentsEnabled, testAttachImageFilename, - testMediaType, testImageDescription, testCity) + testMediaType, testImageDescription, testCity, + testInReplyTo, testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) createPublicPost(baseDir, nickname, domain, port, httpPrefix, "Getting kinda spooky around here", testFollowersOnly, @@ -2343,7 +2363,10 @@ if args.testdata: testCommentsEnabled, testAttachImageFilename, testMediaType, testImageDescription, testCity, - 'someone') + 'someone', testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) createPublicPost(baseDir, nickname, domain, port, httpPrefix, "And they would have gotten away with it too" + "if it wasn't for those pesky hackers", @@ -2352,7 +2375,11 @@ if args.testdata: testC2S, testCommentsEnabled, 'img/logo.png', 'image/png', - 'Description of image', testCity) + 'Description of image', testCity, + testInReplyTo, testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) createPublicPost(baseDir, nickname, domain, port, httpPrefix, "man these centralized sites are like the worst!", testFollowersOnly, @@ -2360,7 +2387,11 @@ if args.testdata: testC2S, testCommentsEnabled, testAttachImageFilename, - testMediaType, testImageDescription, testCity) + testMediaType, testImageDescription, testCity, + testInReplyTo, testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) createPublicPost(baseDir, nickname, domain, port, httpPrefix, "another mystery solved #test", testFollowersOnly, @@ -2368,7 +2399,11 @@ if args.testdata: testC2S, testCommentsEnabled, testAttachImageFilename, - testMediaType, testImageDescription, testCity) + testMediaType, testImageDescription, testCity, + testInReplyTo, testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) createPublicPost(baseDir, nickname, domain, port, httpPrefix, "let's go bowling", testFollowersOnly, @@ -2376,8 +2411,11 @@ if args.testdata: testC2S, testCommentsEnabled, testAttachImageFilename, - testMediaType, testImageDescription, testCity) - + testMediaType, testImageDescription, testCity, + testInReplyTo, testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) domainFull = domain + ':' + str(port) clearFollows(baseDir, nickname, domain) followPerson(baseDir, nickname, domain, 'maxboardroom', domainFull, diff --git a/posts.py b/posts.py index 0ebcc2529..b95374f1e 100644 --- a/posts.py +++ b/posts.py @@ -1426,12 +1426,12 @@ def createPublicPost(baseDir: str, clientToServer: bool, commentsEnabled: bool, attachImageFilename: str, mediaType: str, imageDescription: str, city: str, - inReplyTo: str = None, - inReplyToAtomUri: str = None, subject: str = None, - schedulePost: bool = False, - eventDate: str = None, eventTime: str = None, - location: str = None, - isArticle: bool = False) -> {}: + inReplyTo: str, + inReplyToAtomUri: str, subject: str, + schedulePost: bool, + eventDate: str, eventTime: str, + location: str, + isArticle: bool) -> {}: """Public post """ domainFull = getFullDomain(domain, port) diff --git a/tests.py b/tests.py index 972541101..9496820ac 100644 --- a/tests.py +++ b/tests.py @@ -477,6 +477,14 @@ def createServerAlice(path: str, domain: str, port: int, testMediaType = None testImageDescription = None testCity = 'London, England' + testInReplyTo = None + testInReplyToAtomUri = None + testSubject = None + testSchedulePost = False + testEventDate = None + testEventTime = None + testLocation = None + testIsArticle = False createPublicPost(path, nickname, domain, port, httpPrefix, "No wise fish would go anywhere without a porpoise", testFollowersOnly, @@ -485,7 +493,11 @@ def createServerAlice(path: str, domain: str, port: int, testCommentsEnabled, testAttachImageFilename, testMediaType, - testImageDescription, testCity) + testImageDescription, testCity, + testInReplyTo, testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) createPublicPost(path, nickname, domain, port, httpPrefix, "Curiouser and curiouser!", testFollowersOnly, @@ -494,7 +506,11 @@ def createServerAlice(path: str, domain: str, port: int, testCommentsEnabled, testAttachImageFilename, testMediaType, - testImageDescription, testCity) + testImageDescription, testCity, + testInReplyTo, testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) createPublicPost(path, nickname, domain, port, httpPrefix, "In the gardens of memory, in the palace " + "of dreams, that is where you and I shall meet", @@ -504,7 +520,11 @@ def createServerAlice(path: str, domain: str, port: int, testCommentsEnabled, testAttachImageFilename, testMediaType, - testImageDescription, testCity) + testImageDescription, testCity, + testInReplyTo, testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) global testServerAliceRunning testServerAliceRunning = True maxMentions = 10 @@ -582,6 +602,14 @@ def createServerBob(path: str, domain: str, port: int, testImageDescription = None testMediaType = None testCity = 'London, England' + testInReplyTo = None + testInReplyToAtomUri = None + testSubject = None + testSchedulePost = False + testEventDate = None + testEventTime = None + testLocation = None + testIsArticle = False createPublicPost(path, nickname, domain, port, httpPrefix, "It's your life, live it your way.", testFollowersOnly, @@ -590,7 +618,11 @@ def createServerBob(path: str, domain: str, port: int, testCommentsEnabled, testAttachImageFilename, testMediaType, - testImageDescription, testCity) + testImageDescription, testCity, + testInReplyTo, testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) createPublicPost(path, nickname, domain, port, httpPrefix, "One of the things I've realised is that " + "I am very simple", @@ -600,7 +632,11 @@ def createServerBob(path: str, domain: str, port: int, testCommentsEnabled, testAttachImageFilename, testMediaType, - testImageDescription, testCity) + testImageDescription, testCity, + testInReplyTo, testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) createPublicPost(path, nickname, domain, port, httpPrefix, "Quantum physics is a bit of a passion of mine", testFollowersOnly, @@ -609,7 +645,11 @@ def createServerBob(path: str, domain: str, port: int, testCommentsEnabled, testAttachImageFilename, testMediaType, - testImageDescription, testCity) + testImageDescription, testCity, + testInReplyTo, testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) global testServerBobRunning testServerBobRunning = True maxMentions = 10 @@ -1435,10 +1475,28 @@ def _testCreatePerson(): setBio(baseDir, nickname, domain, 'Randomly roaming in your backyard') archivePostsForPerson(nickname, domain, baseDir, 'inbox', None, {}, 4) archivePostsForPerson(nickname, domain, baseDir, 'outbox', None, {}, 4) + testInReplyTo = None + testInReplyToAtomUri = None + testSubject = None + testSchedulePost = False + testEventDate = None + testEventTime = None + testLocation = None + testIsArticle = False + content = "G'day world!" + followersOnly = False + saveToFile = True + commentsEnabled = True + attachImageFilename = None + mediaType = None createPublicPost(baseDir, nickname, domain, port, httpPrefix, - "G'day world!", False, True, clientToServer, - True, None, None, None, None, - 'Not suitable for Vogons', 'London, England') + content, followersOnly, saveToFile, clientToServer, + commentsEnabled, attachImageFilename, mediaType, + 'Not suitable for Vogons', 'London, England', + testInReplyTo, testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) os.chdir(currDir) shutil.rmtree(baseDir) @@ -2821,12 +2879,23 @@ def _testReplyToPublicPost() -> None: mediaType = None imageDescription = 'Some description' city = 'London, England' + testInReplyToAtomUri = None + testSubject = None + testSchedulePost = False + testEventDate = None + testEventTime = None + testLocation = None + testIsArticle = False reply = \ createPublicPost(baseDir, nickname, domain, port, httpPrefix, content, followersOnly, saveToFile, clientToServer, commentsEnabled, attachImageFilename, mediaType, - imageDescription, city, postId) + imageDescription, city, postId, + testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) # print(str(reply)) assert reply['object']['content'] == \ '

' + \ @@ -3384,16 +3453,30 @@ def _testLinksWithinPost() -> None: saveToFile = False clientToServer = False commentsEnabled = True + attachImageFilename = None mediaType = None imageDescription = None city = 'London, England' + testInReplyTo = None + testInReplyToAtomUri = None + testSubject = None + testSchedulePost = False + testEventDate = None + testEventTime = None + testLocation = None + testIsArticle = False postJsonObject = \ createPublicPost(baseDir, nickname, domain, port, httpPrefix, content, followersOnly, saveToFile, clientToServer, commentsEnabled, - mediaType, imageDescription, city, - False, None) + attachImageFilename, mediaType, + imageDescription, city, + testInReplyTo, testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) + assert postJsonObject['object']['content'] == \ '

This is a test post with links.

' + \ ' None: postJsonObject = \ createPublicPost(baseDir, nickname, domain, port, httpPrefix, content, - False, False, False, True, - None, None, False, None) + False, False, + False, True, + None, None, + False, None, + testInReplyTo, testInReplyToAtomUri, + testSubject, testSchedulePost, + testEventDate, testEventTime, testLocation, + testIsArticle) assert postJsonObject['object']['content'] == content