Skip to content

Commit

Permalink
adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneswilm committed Mar 9, 2023
1 parent 9dc79df commit 20b6d24
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
21 changes: 10 additions & 11 deletions fiduswriter/phplist/tests/test_phplist.py
@@ -1,5 +1,4 @@
import time
import json
import multiprocessing
from http.server import BaseHTTPRequestHandler, HTTPServer
import cgi
Expand All @@ -22,7 +21,7 @@
# From https://realpython.com/testing-third-party-apis-with-mock-servers/
class MockServerRequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
if self.path != "/admin/?page=call&pi=restapi":
if self.path != "/admin/?page=importsimple":
self.send_response(requests.codes.not_found)
self.end_headers()
return
Expand All @@ -34,23 +33,23 @@ def do_POST(self):
"CONTENT_TYPE": self.headers["Content-Type"],
},
)
cmd = form["cmd"].value
if cmd == "login":
if "cmd" in form and form["cmd"].value == "login":
self.send_response(requests.codes.ok)
self.send_header("Set-Cookie", "fish=2000")
self.end_headers()
elif cmd == "subscriberAdd":
self.send_response(requests.codes.ok)
self.send_header("Content-Type", "application/json")
self.end_headers()
self.wfile.write(
json.dumps({"status": "OK", "data": {"id": 19}}).encode(
encoding="utf_8"
'<html><head></head><body><input type="hidden" name="formtoken" value="1f2342432j4bn3b237114" /></body></html>'.encode(
"utf-8"
)
)
elif cmd == "listSubscriberAdd":
elif "importcontent" in form:
self.send_response(requests.codes.ok)
self.end_headers()
self.wfile.write(
"<html><head></head><body>Email has been subscribed!</body></html>".encode(
"utf-8"
)
)
else:
self.send_response(requests.codes.not_found)
self.end_headers()
Expand Down
3 changes: 0 additions & 3 deletions fiduswriter/phplist/views.py
@@ -1,4 +1,3 @@
import json
import re
from httpx import AsyncClient, HTTPError
from asgiref.sync import async_to_sync, sync_to_async
Expand Down Expand Up @@ -31,7 +30,6 @@ async def subscribe_email(request):
url,
params={"page": "importsimple"},
headers={
"Accept": "application/json",
"Content-Type": "application/x-www-form-urlencoded",
},
content=urlencode(login_data),
Expand Down Expand Up @@ -68,7 +66,6 @@ async def subscribe_email(request):
url,
params={"page": "importsimple"},
headers={
"Accept": "application/json",
"Cookie": session_cookie,
"Content-Type": "application/x-www-form-urlencoded",
},
Expand Down

0 comments on commit 20b6d24

Please sign in to comment.