from yaml import load, SafeLoader
from os import environ

from execute import run


EXTERNAL_DOMAIN = 'google.fr'


def test_dns_external():
    conf_file = f'{environ["MACHINE_TEST_DIR"]}/dns-local.yml'
    with open(conf_file) as yaml:
        data = load(yaml, Loader=SafeLoader)
    result = run(data['address'],
                 ['/bin/resolvectl', 'query', EXTERNAL_DOMAIN],
                 )
    assert 'resolve call failed' not in next(result), f'cannot resolved {EXTERNAL_DOMAIN}'
