Refactored test to allow address and port changed.
This commit is contained in:
parent
64042f0371
commit
d92761ed70
@ -8,12 +8,36 @@ class Server:
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initialization of a server."""
|
"""Initialization of a server."""
|
||||||
self.settings = {}
|
self.env = {}
|
||||||
self.settings["address"] = "127.0.0.1"
|
|
||||||
self.settings["port"] = 9090
|
|
||||||
self.process = None
|
self.process = None
|
||||||
self.loop = get_event_loop()
|
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 def __start(self):
|
||||||
"""async start of the server."""
|
"""async start of the server."""
|
||||||
self.process = await create_subprocess_exec(
|
self.process = await create_subprocess_exec(
|
||||||
|
@ -16,7 +16,7 @@ def start_server(server):
|
|||||||
@when("the home page is accessed")
|
@when("the home page is accessed")
|
||||||
def access_home_page(server, page):
|
def access_home_page(server, page):
|
||||||
"""Access the home 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)
|
page.request_url(url)
|
||||||
|
|
||||||
@then("the status should be OK")
|
@then("the status should be OK")
|
||||||
|
Loading…
Reference in New Issue
Block a user