45 lines
1013 B
Python
45 lines
1013 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 record
|
|
record(filled_dir, message='test_record_untracked_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
|
|
|