add more simple init tests
Some checks failed
Ruff / ruff (push) Waiting to run
Mypy / mypy (push) Successful in 44s
Pytest / pytest (3.12) (push) Successful in 50s
Pytest / pytest (3.13) (push) Has been cancelled
Pytest / pytest (3.14) (push) Has been cancelled

This commit is contained in:
Justus Kuhlmann 2025-12-04 14:44:05 +01:00
commit 0be5cb18e2
Signed by: jkuhl
GPG key ID: 00ED992DD79B85A6

View file

@ -9,6 +9,29 @@ def test_init_folders(tmp_path):
assert os.path.exists(str(dataset_path / "backlogger.db")) assert os.path.exists(str(dataset_path / "backlogger.db"))
def test_init_folders_no_tracker(tmp_path):
dataset_path = tmp_path / "test_dataset"
init.create(str(dataset_path), tracker="None")
assert os.path.exists(str(dataset_path))
assert os.path.exists(str(dataset_path / "backlogger.db"))
def test_init_config(tmp_path):
dataset_path = tmp_path / "test_dataset"
init.create(str(dataset_path), tracker="None")
config_path = dataset_path / ".corrlib"
assert os.path.exists(str(config_path))
from configparser import ConfigParser
config = ConfigParser()
config.read(str(config_path))
assert config.get("core", "tracker") == "None"
assert config.get("paths", "db") == "backlogger.db"
assert config.get("paths", "projects_path") == "projects"
assert config.get("paths", "archive_path") == "archive"
assert config.get("paths", "toml_imports_path") == "toml_imports"
assert config.get("paths", "import_scripts_path") == "import_scripts"
def test_init_db(tmp_path): def test_init_db(tmp_path):
dataset_path = tmp_path / "test_dataset" dataset_path = tmp_path / "test_dataset"
init.create(str(dataset_path)) init.create(str(dataset_path))
@ -24,7 +47,7 @@ def test_init_db(tmp_path):
table_names = [table[0] for table in tables] table_names = [table[0] for table in tables]
for expected_table in expected_tables: for expected_table in expected_tables:
assert expected_table in table_names assert expected_table in table_names
cursor.execute("SELECT * FROM projects;") cursor.execute("SELECT * FROM projects;")
projects = cursor.fetchall() projects = cursor.fetchall()
assert len(projects) == 0 assert len(projects) == 0
@ -47,7 +70,7 @@ def test_init_db(tmp_path):
project_column_names = [col[1] for col in project_columns] project_column_names = [col[1] for col in project_columns]
for expected_col in expected_project_columns: for expected_col in expected_project_columns:
assert expected_col in project_column_names assert expected_col in project_column_names
cursor.execute("PRAGMA table_info('backlogs');") cursor.execute("PRAGMA table_info('backlogs');")
backlog_columns = cursor.fetchall() backlog_columns = cursor.fetchall()
expected_backlog_columns = [ expected_backlog_columns = [