"""
Extra configurations to allow for parameterized tests.

:copyright: Copyright 2013-2016, Dorian Pula <dorian.pula@amber-penguin-software.ca>
:license: AGPL v3+
"""

import pytest


def pytest_addoption(parser):
    parser.addoption("--server-hostname", action="store", default="localhost",
                     help="hostname of server under test: localhost, 127.0.0.1, myremote-server.net...")
    parser.addoption("--server-port", action="store", default="5000", help="port of server under test: 5000")


@pytest.fixture
def api_base_uri(request):
    """
    The base URI of the API server to build request to API.  The base URI is the format http://hostname:port, provided
    by the server hostname and server port pytest parameters.

    :param request: The request for the test.
    :return: The base URI of the API server.
    """
    server_hostname = request.config.getoption("--server-hostname")
    server_port = request.config.getoption("--server-port")
    return f"http://{server_hostname}:{server_port}"
