nancy/tests/test_store.py
Jacob Hinkle f55d110e49 Programs are now recorded in the store.
The record() program and cli is not yet working. For that we need a
working `FSDiff` next.  Then we'll finally be ready to start recording
file information.
2022-09-21 21:23:20 -04:00

45 lines
982 B
Python

import os
from pathlib import Path
import pytest
import sys
import tempfile
@pytest.fixture
def bare_dir():
"""Create an emptry temp directory"""
with tempfile.TemporaryDirectory(prefix="nancy_testdir") as d:
yield Path(d)
@pytest.fixture
def filled_dir(bare_dir):
open(bare_dir / 'a.txt', 'w').write("foo")
os.makedirs(bare_dir / 'stats')
open(bare_dir / 'stats' / 'metrics.csv', 'w').write("bar,baz")
# identical to ./a.txt
open(bare_dir / 'stats' / 'a.txt', 'w').write("foo")
return bare_dir
def test_record_untracked_dir(filled_dir):
from nancy.cli.record import do_record
do_record(filled_dir)
@pytest.fixture
def store():
from nancy import store
s = store.Store.init()
yield s
def test_schema_version_match(store):
from nancy.version import schema_version
cur = store.conn.cursor()
(db_schema_ver,) = cur.execute("PRAGMA user_version;").fetchone()
assert schema_version == db_schema_ver