import logging, os, pytest, sys

from pathlib import Path
sys.path.append(__file__.split('src')[0] + 'src')
print(sys.path)

from context.client.ContextClient import ContextClient
from context.proto.context_pb2 import Empty
from .tools.ValidateTopology import validate_topology_dict

LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG)

@pytest.fixture(scope='session')
def remote_context_client():
    address = os.environ.get('TEST_TARGET_ADDRESS')
    if(address is None): raise Exception('EnvironmentVariable(TEST_TARGET_ADDRESS) not specified')
    port = os.environ.get('TEST_TARGET_PORT')
    if(port is None): raise Exception('EnvironmentVariable(TEST_TARGET_PORT) not specified')
    return ContextClient(address=address, port=port)

def test_remote_get_topology(remote_context_client):
    response = remote_context_client.GetTopology(Empty())
    validate_topology_dict(response)
