test init by itself
This commit is contained in:
parent
574877c744
commit
0af1b4e4a4
1 changed files with 68 additions and 0 deletions
68
tests/test_initialization.py
Normal file
68
tests/test_initialization.py
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
import corrlib.initialization as init
|
||||||
|
import os
|
||||||
|
import sqlite3 as sql
|
||||||
|
|
||||||
|
def test_init_folders(tmp_path):
|
||||||
|
dataset_path = tmp_path / "test_dataset"
|
||||||
|
init.create(str(dataset_path))
|
||||||
|
assert os.path.exists(str(dataset_path))
|
||||||
|
assert os.path.exists(str(dataset_path / "backlogger.db"))
|
||||||
|
|
||||||
|
|
||||||
|
def test_init_db(tmp_path):
|
||||||
|
dataset_path = tmp_path / "test_dataset"
|
||||||
|
init.create(str(dataset_path))
|
||||||
|
assert os.path.exists(str(dataset_path / "backlogger.db"))
|
||||||
|
conn = sql.connect(str(dataset_path / "backlogger.db"))
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
|
||||||
|
tables = cursor.fetchall()
|
||||||
|
expected_tables = [
|
||||||
|
'projects',
|
||||||
|
'backlogs',
|
||||||
|
]
|
||||||
|
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
|
||||||
|
|
||||||
|
cursor.execute("SELECT * FROM backlogs;")
|
||||||
|
backlogs = cursor.fetchall()
|
||||||
|
assert len(backlogs) == 0
|
||||||
|
|
||||||
|
cursor.execute("PRAGMA table_info('projects');")
|
||||||
|
project_columns = cursor.fetchall()
|
||||||
|
expected_project_columns = [
|
||||||
|
"id",
|
||||||
|
"aliases",
|
||||||
|
"customTags",
|
||||||
|
"owner",
|
||||||
|
"code",
|
||||||
|
"created_at",
|
||||||
|
"updated_at"
|
||||||
|
]
|
||||||
|
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 = [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"ensemble",
|
||||||
|
"code",
|
||||||
|
"path",
|
||||||
|
"project",
|
||||||
|
"customTags",
|
||||||
|
"parameters",
|
||||||
|
"parameter_file",
|
||||||
|
"created_at",
|
||||||
|
"updated_at"
|
||||||
|
]
|
||||||
|
backlog_column_names = [col[1] for col in backlog_columns]
|
||||||
|
for expected_col in expected_backlog_columns:
|
||||||
|
assert expected_col in backlog_column_names
|
||||||
Loading…
Add table
Add a link
Reference in a new issue