tests: add support for loading a database

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2022-02-21 20:17:17 -05:00
parent f2f1d413d4
commit 3edb4b1bad
3 changed files with 24 additions and 2 deletions

View File

@ -1,6 +1,6 @@
[pytest] [pytest]
minversion = 7.0 minversion = 7.0
pythonpath = moonraker pythonpath = moonraker scripts
testpaths = tests testpaths = tests
required_plugins = required_plugins =
pytest-asyncio>=0.17.2 pytest-asyncio>=0.17.2

View File

@ -0,0 +1,16 @@
+32,24:TU9PTlJBS0VSX0RBVEFCQVNFX1NUQVJU->bmFtZXNwYWNlX2NvdW50PTU=
+36,12:bmFtZXNwYWNlX2F1dGhvcml6ZWRfdXNlcnM=->ZW50cmllcz0x
+20,148:X0FQSV9LRVlfVVNFUl8=->eyJ1c2VybmFtZSI6ICJfQVBJX0tFWV9VU0VSXyIsICJhcGlfa2V5IjogIjg4ZTdlMjA0MDU3YjQzYTdiNTI3ZGEwZDQzNjQ1MDg5IiwgImNyZWF0ZWRfb24iOiAxNjQ1NDkwOTExLjM5NzI1OTd9
+32,12:bmFtZXNwYWNlX2djb2RlX21ldGFkYXRh->ZW50cmllcz0w
+24,12:bmFtZXNwYWNlX2hpc3Rvcnk=->ZW50cmllcz0w
+28,12:bmFtZXNwYWNlX21vb25yYWtlcg==->ZW50cmllcz0z
+12,236:ZGF0YWJhc2U=->eyJkZWJ1Z19jb3VudGVyIjogMiwgInVuc2FmZV9zaHV0ZG93bnMiOiAxLCAicHJvdGVjdGVkX25hbWVzcGFjZXMiOiBbImdjb2RlX21ldGFkYXRhIiwgImhpc3RvcnkiLCAibW9vbnJha2VyIiwgInVwZGF0ZV9tYW5hZ2VyIl0sICJmb3JiaWRkZW5fbmFtZXNwYWNlcyI6IFsiYXV0aG9yaXplZF91c2VycyJdfQ==
+24,12:ZGF0YWJhc2VfdmVyc2lvbg==->cQEAAAAAAAAA
+16,84:ZmlsZV9tYW5hZ2Vy->eyJtZXRhZGF0YV92ZXJz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GY2NDBkYzEzNTA5YiIsICJ1cHN0cmVhbV91cmwiOiAiaHR0cHM6Ly9naXRodWIuY29tL2Fya3NpbmUvbW9vbnRlc3QuZ2l0IiwgImZ1bGxfdmVyc2lvbl9zdHJpbmciOiAidjAuMC4xLTItZzViNGI5NDgiLCAiYnJhbmNoZXMiOiBbIm1hc3RlciJdLCAiZGlydHkiOiBmYWxzZSwgImhlYWRfZGV0YWNoZWQiOiBmYWxzZSwgImdpdF9tZXNzYWdlcyI6IFtdLCAiY29tbWl0c19iZWhpbmQiOiBbXX0=
+8,108:c3lzdGVt->eyJsYXN0X2NvbmZpZ19oYXNoIjogIiIsICJsYXN0X3JlZnJlc2hfdGltZSI6IDE2NDU0OTA5MTQuMTU3MzQwOCwgInBhY2thZ2VzIjogW119

View File

@ -13,6 +13,7 @@ from typing import Iterator, Dict, AsyncIterator, Any
from moonraker import Server from moonraker import Server
from eventloop import EventLoop from eventloop import EventLoop
import utils import utils
import dbtool
from fixtures import KlippyProcess, HttpClient, WebsocketClient from fixtures import KlippyProcess, HttpClient, WebsocketClient
ASSETS = pathlib.Path(__file__).parent.joinpath("assets") ASSETS = pathlib.Path(__file__).parent.joinpath("assets")
@ -133,7 +134,7 @@ def path_args(request: pytest.FixtureRequest,
"moonraker_conf": "base_server.conf", "moonraker_conf": "base_server.conf",
"secrets": "secrets.ini", "secrets": "secrets.ini",
"printer_cfg": "base_printer.cfg", "printer_cfg": "base_printer.cfg",
"klippy_uds": None "klippy_uds": None,
} }
if path_marker is not None: if path_marker is not None:
paths.update(path_marker.kwargs) paths.update(path_marker.kwargs)
@ -171,6 +172,11 @@ def path_args(request: pytest.FixtureRequest,
bkp_source = ASSETS.joinpath("moonraker/base_server.conf") bkp_source = ASSETS.joinpath("moonraker/base_server.conf")
bkp_dest = cfg_path.joinpath(paths["moonraker_bkp"]) bkp_dest = cfg_path.joinpath(paths["moonraker_bkp"])
interpolate_config(bkp_source, bkp_dest, session_args) interpolate_config(bkp_source, bkp_dest, session_args)
if "database" in paths:
db_source = ASSETS.joinpath(f"moonraker/{paths['database']}")
db_dest = session_args["database_path"]
db_args = {"input": str(db_source), "destination": db_dest}
dbtool.restore(db_args)
yield session_args yield session_args
log = session_args.pop("moonraker.log", None) log = session_args.pop("moonraker.log", None)
if log is not None and log.is_file(): if log is not None and log.is_file():