Coverage for test_server.py: 97%
32 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-07 06:52 +0200
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-07 06:52 +0200
1from edictor.server import Handler
2import tempfile
3import os
5class FileLike:
7 def close(self):
8 pass
10 def readline(self, x):
11 return b"1234"
13 def read(self, x):
14 return b"1234"
17class Rfile:
19 def __init__(self, x):
20 self.x = x
22 def read(self, n):
23 return bytes(self.x, "utf-8")
26class Tester:
28 def __init__(self):
29 self.makefile = lambda x, y: FileLike()
31 def sendall(self, x):
32 return x
35def test_Handler():
37 wd = os.getcwd()
38 with tempfile.TemporaryDirectory() as t:
39 os.chdir(t)
40 han = Handler(Tester(), "https://localhost:1234", "")
41 for fn, path in [
42 ("/", ""),
43 ("/data/test.tsv", ""),
44 ("/index.html", ""),
45 ("/download.py", "file=germanic.tsv&data=abcdefg"),
46 ("/triples/triples.py", "file=germanic&remote_dbase=germanic"),
47 ("/check.py", ""),
48 #("/update.py",
49 #"/triples/new_id.py",
50 #"/triples/modifications.py",
51 #"/alignments.py",
52 #"/cognates.py",
53 #"/patterns.py"
54 ]:
55 han.headers = {"Content-Length": "10"}
56 han.rfile = Rfile(path)
57 han.path = fn + "?" + path
58 han.do_GET()
59 han.do_POST()
60 os.chdir(wd)