Verified Commit 84fe1988 authored by Vojtech Myslivec's avatar Vojtech Myslivec
Browse files

tests: Use one common helper for DB preparation

parent f1ea8fc7
......@@ -2,20 +2,11 @@
PyTest init, mocks and fixtures
"""
import contextlib
import sqlite3
import pytest
from sentinel_ca.sn import prepare_config
def prepare_db_scheme(db_path, scheme_path):
with sqlite3.connect(db_path) as conn:
with contextlib.closing(conn.cursor()) as c:
with open(scheme_path) as scheme:
c.executescript(scheme.read())
conn.commit()
from ..helpers import prepare_db_scheme
@pytest.fixture(params=[
......
......@@ -21,10 +21,10 @@ def bytes_to_dict(b):
return json.loads(str(b), encoding='utf-8')
def prepare_db(db_path):
def prepare_db_scheme(db_path, scheme_path="scheme.sql"):
with sqlite3.connect(db_path) as conn:
with contextlib.closing(conn.cursor()) as c:
with open("scheme.sql") as scheme:
with open(scheme_path) as scheme:
c.executescript(scheme.read())
conn.commit()
......@@ -52,7 +52,7 @@ def build_ca_config(tmpdir, expire_soon=False, wrong_key=False):
# Generate the db
db_path = tmpdir.join("ca.db")
prepare_db(str(db_path))
prepare_db_scheme(str(db_path))
# Build the config
# apply sentinel_ca config defaults
......
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