2018-08-01 17:05:43 +02:00
|
|
|
"""pytest fixtures"""
|
|
|
|
|
from importlib import reload
|
|
|
|
|
import os
|
|
|
|
|
import types
|
|
|
|
|
from unittest import mock
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
import tljh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def tljh_dir(tmpdir):
|
|
|
|
|
"""Fixture for setting up a temporary tljh dir"""
|
|
|
|
|
tljh_dir = str(tmpdir.join("tljh").mkdir())
|
|
|
|
|
with mock.patch.dict(os.environ, {"TLJH_INSTALL_PREFIX": tljh_dir}):
|
|
|
|
|
reload(tljh)
|
|
|
|
|
for name in dir(tljh):
|
|
|
|
|
mod = getattr(tljh, name)
|
2021-11-03 23:55:34 +01:00
|
|
|
if isinstance(mod, types.ModuleType) and mod.__name__.startswith("tljh."):
|
2018-08-01 17:05:43 +02:00
|
|
|
reload(mod)
|
|
|
|
|
assert tljh.config.INSTALL_PREFIX == tljh_dir
|
|
|
|
|
os.makedirs(tljh.config.STATE_DIR)
|
2018-08-29 09:45:15 +02:00
|
|
|
os.makedirs(tljh.config.CONFIG_DIR)
|
2020-06-02 18:20:28 +03:00
|
|
|
os.makedirs(os.path.join(tljh.config.CONFIG_DIR, "traefik_config.d"))
|
2018-08-01 17:05:43 +02:00
|
|
|
yield tljh_dir
|