diff --git a/tests/step_defs/server.py b/tests/step_defs/server.py index 4057327..0330f07 100644 --- a/tests/step_defs/server.py +++ b/tests/step_defs/server.py @@ -8,12 +8,36 @@ class Server: def __init__(self): """Initialization of a server.""" - self.settings = {} - self.settings["address"] = "127.0.0.1" - self.settings["port"] = 9090 + self.env = {} self.process = None self.loop = get_event_loop() + @property + def address(self): + """Get the server address.""" + address = "127.0.0.1" + if "MMT_ADDRESS" in self.env: + address = self.env["MMT_ADDRESS"] + return address + + @address.setter + def address(self, addr): + """Sets the server address.""" + self.env["MTT_ADDRESS"] = addr + + @property + def port(self): + """Get the port of the server.""" + port = 9090 + if "MTT_PORT" in self.env: + port = self.env["MTT_PORT"] + return port + + @port.setter + def port(self, num): + """Set the port for the server.""" + self.env["MTT_PORT"] = num + async def __start(self): """async start of the server.""" self.process = await create_subprocess_exec( diff --git a/tests/step_defs/test_server_start.py b/tests/step_defs/test_server_start.py index 50af13a..9d2c51c 100644 --- a/tests/step_defs/test_server_start.py +++ b/tests/step_defs/test_server_start.py @@ -16,7 +16,7 @@ def start_server(server): @when("the home page is accessed") def access_home_page(server, page): """Access the home page.""" - url = f"http://{server.settings['address']}:{server.settings['port']}/" + url = f"http://{server.address}:{server.port}/" page.request_url(url) @then("the status should be OK")