]> www.average.org Git - loctrkd.git/blobdiff - test/common.py
rename `lookaside` to `rectifier`
[loctrkd.git] / test / common.py
index 1672f46029c663eb79436d0add7bbc5ef9259227..761ea6721a267c832af4d3dfca910f6cbbb2dbb9 100644 (file)
@@ -4,6 +4,7 @@ from configparser import ConfigParser, SectionProxy
 from contextlib import closing, ExitStack
 from http.server import HTTPServer, SimpleHTTPRequestHandler
 from importlib import import_module
+from logging import DEBUG, StreamHandler
 from multiprocessing import Process
 from os import kill, unlink
 from signal import SIGINT
@@ -16,7 +17,7 @@ from socket import (
     socket,
     SocketType,
 )
-from sys import exit
+from sys import exit, stderr
 from tempfile import mkstemp
 from time import sleep
 from typing import Optional
@@ -26,7 +27,9 @@ NUMPORTS = 3
 
 
 class TestWithServers(TestCase):
-    def setUp(self, *args: str, httpd: bool = False) -> None:
+    def setUp(
+        self, *args: str, httpd: bool = False, verbose: bool = False
+    ) -> None:
         freeports = []
         with ExitStack() as stack:
             for _ in range(NUMPORTS):
@@ -40,6 +43,7 @@ class TestWithServers(TestCase):
             "port": str(freeports[0]),
             "publishurl": "ipc://" + self.tmpfilebase + ".pub",
             "listenurl": "ipc://" + self.tmpfilebase + ".pul",
+            "protocols": "zx303proto",
         }
         self.conf["storage"] = {
             "dbfn": self.tmpfilebase + ".storage.sqlite",
@@ -48,7 +52,7 @@ class TestWithServers(TestCase):
             "dbfn": self.tmpfilebase + ".opencellid.sqlite",
             "downloadurl": f"http://localhost:{freeports[2]}/test/262.csv.gz",
         }
-        self.conf["lookaside"] = {
+        self.conf["rectifier"] = {
             "backend": "opencellid",
         }
         self.conf["wsgateway"] = {
@@ -60,7 +64,10 @@ class TestWithServers(TestCase):
                 kwargs = {"handle_hibernate": False}
             else:
                 kwargs = {}
-            cls = import_module("gps303." + srvname, package=".")
+            cls = import_module("loctrkd." + srvname, package=".")
+            if verbose:
+                cls.log.addHandler(StreamHandler(stderr))
+                cls.log.setLevel(DEBUG)
             p = Process(target=cls.runserver, args=(self.conf,), kwargs=kwargs)
             p.start()
             self.children.append((srvname, p))