Commit da87cebf authored by Samuel GAIST's avatar Samuel GAIST

[tests][common] Setup the simple_rawdata_access/1 database so that it can be...

[tests][common] Setup the simple_rawdata_access/1 database so that it can be used for raw access tests
parent d995075e
......@@ -25,6 +25,7 @@
# #
###############################################################################
import json
import os
from django.conf import settings
......@@ -104,14 +105,32 @@ class BackendUtilitiesMixin(object):
environment=dict(name=env.name, version=env.version),
)
raw_access_db_name = "simple_rawdata_access/1"
source_prefix = os.path.join(settings.BASE_DIR, "src", "beat.examples")
db_root_file_path = os.path.join(settings.PREFIX, "db_root.json")
db_path = os.path.join(
settings.PREFIX, "data", raw_access_db_name.replace("/", "_")
)
db_root_data = {raw_access_db_name: db_path}
os.makedirs(db_path, exist_ok=True)
with open(os.path.join(db_path, "datafile.txt"), "wt") as datafile:
datafile.write("1")
install.install_contributions(source_prefix, "system", template_data)
install.install_contributions(source_prefix, "test", template_data)
with open(db_root_file_path, "wt") as db_root_file:
db_root_file.write(json.dumps(db_root_data))
for contribution in ["system", "test"]:
install.install_contributions(
source_prefix, contribution, template_data, db_root_file_path
)
if not os.path.exists(settings.CACHE_ROOT):
os.mkdir(settings.CACHE_ROOT)
os.remove(db_root_file_path)
def clean_cache(self):
for p, dirs, files in os.walk(settings.CACHE_ROOT, topdown=False):
......
Markdown is supported
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