Allow port to be changed using MTT_PORT environment variable.

This commit is contained in:
2022-06-11 18:10:23 -04:00
parent d92761ed70
commit e40e190e1e
8 changed files with 597 additions and 30 deletions

View File

@@ -1,24 +1,40 @@
"""Interpratures for server start features."""
from pytest_bdd import given, scenarios, then, when
from pytest_bdd import given, parsers, scenarios, then, when
scenarios("../features/server_start.feature")
@given("a server")
def create_server(server):
def create_server():
"""Set up a server."""
@given(parsers.re(r"address is set to (?P<addr>\S+)"))
def set_server_address(server, addr):
"""Set the Server address."""
server.address = addr
@given("port is changed to something different")
def set_to_safe_port(server):
"""Set the app server to an unused port."""
server.set_safe_port()
@given("it is running")
def start_server(server):
"""Start up the server."""
server.start()
@when("the home page is accessed")
def access_home_page(server, page):
"""Access the home page."""
url = f"http://{server.address}:{server.port}/"
page.request_url(url)
@then("the status should be OK")
def check_for_ok(page):
"""Is the page status code 200"""