43 lines
917 B
Python
43 lines
917 B
Python
import pytest
|
|
import os
|
|
import libvirt
|
|
import vagrant
|
|
import dotenv
|
|
|
|
@pytest.fixture
|
|
def script():
|
|
is_packaged = False
|
|
script = 'scullery'
|
|
if not is_packaged:
|
|
script = f'{script}.py'
|
|
return script
|
|
|
|
|
|
@pytest.fixture
|
|
def testbase():
|
|
return os.path.abspath(os.path.dirname(os.getenv('PYTEST_CURRENT_TEST')))
|
|
|
|
|
|
@pytest.fixture
|
|
def config(testbase, request):
|
|
return '{}/configs/{}.ini'.format(testbase, request.param)
|
|
|
|
|
|
@pytest.fixture
|
|
def virt():
|
|
return libvirt.openReadOnly('qemu:///system')
|
|
|
|
@pytest.fixture
|
|
def vag():
|
|
return vagrant.Vagrant(quiet_stderr=False, quiet_stdout=False)
|
|
|
|
def loadenv():
|
|
env = os.environ.copy()
|
|
envmap = dotenv.dotenv_values('.scullery_env')
|
|
for variable, value in envmap.items():
|
|
if value is not None:
|
|
if isinstance(value, list):
|
|
value = ','.join(value)
|
|
env[variable] = value
|
|
return env
|