moved config settings to separate module.
This commit is contained in:
@ -14,10 +14,3 @@ Feature: Server Start
|
||||
And it is running
|
||||
When the home page is accessed
|
||||
Then the status should be OK
|
||||
|
||||
#Scenario: Start server with a different address
|
||||
#Given a server
|
||||
#And address is set to 127.250.48.58
|
||||
#And it is running
|
||||
#When the home page is accessed
|
||||
#Then the status should be OK
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
from asyncio import create_subprocess_exec, get_event_loop, sleep
|
||||
from pathlib import Path
|
||||
from socket import socket
|
||||
from socket import gethostname, gethostbyname, socket
|
||||
|
||||
|
||||
class Server:
|
||||
@ -73,3 +73,10 @@ class Server:
|
||||
sock.bind((self.address, 0))
|
||||
self.port = sock.getsockname()[1]
|
||||
sock.close()
|
||||
|
||||
def set_to_host_ip(self):
|
||||
"""Set the server to use something other than localhost."""
|
||||
hostname = gethostname()
|
||||
self.address = gethostbyname(hostname)
|
||||
print(self.address)
|
||||
self.set_safe_port()
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""Interpratures for server start features."""
|
||||
|
||||
from pytest_bdd import given, parsers, scenarios, then, when
|
||||
from pytest_bdd import given, scenarios, then, when
|
||||
|
||||
scenarios("../features/server_start.feature")
|
||||
|
||||
@ -10,10 +10,10 @@ 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("it is not using localhost")
|
||||
def set_server_address(server):
|
||||
"""Sets tthe server to not use localhost."""
|
||||
server.set_to_host_ip()
|
||||
|
||||
|
||||
@given("port is changed to something different")
|
||||
|
Reference in New Issue
Block a user