add typing for tests

This commit is contained in:
Justus Kuhlmann 2026-02-18 10:59:12 +01:00
commit 14d19ce9dd
Signed by: jkuhl
GPG key ID: 00ED992DD79B85A6
5 changed files with 19 additions and 17 deletions

View file

@ -2,18 +2,19 @@ from typer.testing import CliRunner
from corrlib.cli import app
import os
import sqlite3 as sql
from pathlib import Path
runner = CliRunner()
def test_version():
def test_version() -> None:
result = runner.invoke(app, ["--version"])
assert result.exit_code == 0
assert "corrlib" in result.output
def test_init_folders(tmp_path):
def test_init_folders(tmp_path: Path) -> None:
dataset_path = tmp_path / "test_dataset"
result = runner.invoke(app, ["init", "--dataset", str(dataset_path)])
assert result.exit_code == 0
@ -21,7 +22,7 @@ def test_init_folders(tmp_path):
assert os.path.exists(str(dataset_path / "backlogger.db"))
def test_init_db(tmp_path):
def test_init_db(tmp_path: Path) -> None:
dataset_path = tmp_path / "test_dataset"
result = runner.invoke(app, ["init", "--dataset", str(dataset_path)])
assert result.exit_code == 0
@ -37,7 +38,7 @@ def test_init_db(tmp_path):
table_names = [table[0] for table in tables]
for expected_table in expected_tables:
assert expected_table in table_names
cursor.execute("SELECT * FROM projects;")
projects = cursor.fetchall()
assert len(projects) == 0
@ -60,7 +61,7 @@ def test_init_db(tmp_path):
project_column_names = [col[1] for col in project_columns]
for expected_col in expected_project_columns:
assert expected_col in project_column_names
cursor.execute("PRAGMA table_info('backlogs');")
backlog_columns = cursor.fetchall()
expected_backlog_columns = [
@ -81,7 +82,7 @@ def test_init_db(tmp_path):
assert expected_col in backlog_column_names
def test_list(tmp_path):
def test_list(tmp_path: Path) -> None:
dataset_path = tmp_path / "test_dataset"
result = runner.invoke(app, ["init", "--dataset", str(dataset_path)])
assert result.exit_code == 0