Refactored test to allow address and port changed.

This commit is contained in:
Jeff Baskin 2022-06-07 13:53:13 -04:00
parent 64042f0371
commit d92761ed70
2 changed files with 28 additions and 4 deletions

View File

@ -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(

View File

@ -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")