Commit b36b7a81 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[test][conftest] Move prefix sync and cleanup to their own function

This will allow to refresh the prefix content if needed.
parent f4acc75b
......@@ -49,15 +49,9 @@ prefix = os.path.join(prefix_folder, "prefix")
environment_file = os.path.join(prefix, "environment.json")
@pytest.fixture(
scope="module", params=[item for item in AssetType if item is not AssetType.UNKNOWN]
)
def asset_type(request):
return request.param
def sync_prefix():
"""Copy the content of the various package test prefixes in the running test prefix"""
@pytest.fixture(scope="module")
def test_prefix():
prefixes = [
pkg_resources.resource_filename("beat.backend.python.test", "prefix"),
pkg_resources.resource_filename("beat.core.test", "prefix"),
......@@ -66,17 +60,9 @@ def test_prefix():
for path in prefixes:
subprocess.check_call(["rsync", "-arz", path, prefix_folder])
with open(environment_file, "wt") as env_file:
env_file.write(
json.dumps(
{
"Test Env": {"name": "Python 2.7", "version": "1.3.0"},
"Another test Env": {"name": "another test", "version": "1.1.1"},
}
)
)
yield prefix
def clean_prefix():
"""Removes the content of the test prefix(s)"""
shutil.rmtree(prefix_folder)
......@@ -93,6 +79,32 @@ def test_prefix():
pass
@pytest.fixture(
scope="module", params=[item for item in AssetType if item is not AssetType.UNKNOWN]
)
def asset_type(request):
return request.param
@pytest.fixture(scope="module")
def test_prefix():
sync_prefix()
with open(environment_file, "wt") as env_file:
env_file.write(
json.dumps(
{
"Test Env": {"name": "Python 2.7", "version": "1.3.0"},
"Another test Env": {"name": "another test", "version": "1.1.1"},
}
)
)
yield prefix
clean_prefix()
@pytest.fixture(scope="module")
def beat_context(test_prefix):
Context = namedtuple("Context", ["meta"])
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment