2022-06-03 11:52:18 -04:00
|
|
|
"""Interpratures for server start features."""
|
|
|
|
|
2022-06-18 21:24:11 -04:00
|
|
|
from pytest_bdd import given, scenarios, then, when
|
2022-06-03 11:52:18 -04:00
|
|
|
|
|
|
|
scenarios("../features/server_start.feature")
|
|
|
|
|
2022-06-11 18:10:23 -04:00
|
|
|
|
2022-06-03 11:52:18 -04:00
|
|
|
@given("a server")
|
2022-06-11 18:10:23 -04:00
|
|
|
def create_server():
|
2022-06-03 11:52:18 -04:00
|
|
|
"""Set up a server."""
|
|
|
|
|
2022-06-11 18:10:23 -04:00
|
|
|
|
2022-06-18 21:24:11 -04:00
|
|
|
@given("it is not using localhost")
|
|
|
|
def set_server_address(server):
|
|
|
|
"""Sets tthe server to not use localhost."""
|
|
|
|
server.set_to_host_ip()
|
2022-06-11 18:10:23 -04:00
|
|
|
|
|
|
|
|
|
|
|
@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()
|
|
|
|
|
|
|
|
|
2022-06-03 11:52:18 -04:00
|
|
|
@given("it is running")
|
|
|
|
def start_server(server):
|
|
|
|
"""Start up the server."""
|
|
|
|
server.start()
|
|
|
|
|
2022-06-11 18:10:23 -04:00
|
|
|
|
2022-06-03 11:52:18 -04:00
|
|
|
@when("the home page is accessed")
|
|
|
|
def access_home_page(server, page):
|
|
|
|
"""Access the home page."""
|
2022-06-07 13:53:13 -04:00
|
|
|
url = f"http://{server.address}:{server.port}/"
|
2022-06-03 11:52:18 -04:00
|
|
|
page.request_url(url)
|
|
|
|
|
2022-06-11 18:10:23 -04:00
|
|
|
|
2022-06-03 11:52:18 -04:00
|
|
|
@then("the status should be OK")
|
|
|
|
def check_for_ok(page):
|
|
|
|
"""Is the page status code 200"""
|
|
|
|
assert page.get_status_code() == 200
|