Added integration testing.

This commit is contained in:
2022-06-03 11:52:18 -04:00
parent 015edc13c1
commit a9b1920c2f
11 changed files with 311 additions and 3 deletions

40
tests/step_defs/server.py Normal file
View File

@@ -0,0 +1,40 @@
"""Fixture for setting up a single server."""
from asyncio import create_subprocess_exec, get_event_loop, sleep
from pathlib import Path
class Server:
"""Setup a single server."""
def __init__(self):
"""Initialization of a server."""
self.settings = {}
self.settings["address"] = "127.0.0.1"
self.settings["port"] = 9090
self.process = None
self.loop = get_event_loop()
async def __start(self):
"""async start of the server."""
self.process = await create_subprocess_exec(
Path.cwd().joinpath("target", "release", "morethantext_web")
)
await sleep(1)
async def __stop(self):
"""async stop of the server."""
if self.process is not None and self.process.returncode is None:
self.process.terminate()
await self.process.wait()
def start(self):
"""Start the server."""
self.loop.run_until_complete(self.__start())
def stop(self):
"""Stop the server."""
self.loop.run_until_complete(self.__stop())
def destroy(self):
"""Removes the server instance."""
self.stop()