diff --git a/data/reference/Versions.json b/data/reference/Versions.json index f3ff339dd..37aab10b6 100644 --- a/data/reference/Versions.json +++ b/data/reference/Versions.json @@ -185,6 +185,12 @@ "end_date": "2026-04-14", "description": "Spectra provided by BONES Archive" }, + { + "version": "5.4.2026.02", + "start_date": "2026-04-14", + "end_date": "2026-04-14", + "description": "Add database.toml" + }, { "version": "latest", "start_date": "2026-04-14", diff --git a/simple/__init__.py b/database.toml similarity index 54% rename from simple/__init__.py rename to database.toml index 62179e860..09a257b22 100644 --- a/simple/__init__.py +++ b/database.toml @@ -1,11 +1,14 @@ +db_name = "simple_tests" +data_path = "data/" +felis_path = "schema.yaml" -REFERENCE_TABLES = [ +lookup_tables = [ "Publications", "Telescopes", "Instruments", + "Parameters", "PhotometryFilters", "Versions", - "Parameters", "RegimeList", - "CompanionList" -] + "CompanionList", +] \ No newline at end of file diff --git a/simple/schema.yaml b/schema.yaml similarity index 100% rename from simple/schema.yaml rename to schema.yaml diff --git a/tests/conftest.py b/tests/conftest.py index 0dbf0c1e9..34d90e811 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,34 +3,22 @@ import sys import pytest -from astrodb_utils import load_astrodb +from astrodb_utils.loaders import build_db_from_json, DatabaseSettings from astrodbkit.astrodb import Database, create_database sys.path.append("./") # needed for github actions to find the simple module -from simple import REFERENCE_TABLES logger = logging.getLogger("AstroDB") -SCHEMA_PATH = "simple/schema.yaml" - +db_settings=DatabaseSettings(settings_file="database.toml") +SCHEMA_PATH = db_settings.felis_path # Create a fresh SIMPLE database for the data and integrity tests @pytest.fixture(scope="session", autouse=True) def db(): - DB_NAME = "tests/simple_tests.sqlite" - DB_PATH = "data" - - if os.path.exists(DB_NAME): - os.remove(DB_NAME) - connection_string = "sqlite:///" + DB_NAME - create_database(connection_string, felis_schema=SCHEMA_PATH) - assert os.path.exists(DB_NAME) - - # Connect to the new database - db = load_astrodb(DB_NAME, - data_path=DB_PATH, - reference_tables=REFERENCE_TABLES, - felis_schema=SCHEMA_PATH) + db = build_db_from_json( + settings_file="database.toml" + ) return db diff --git a/tests/test_felis.py b/tests/test_felis.py index 13b2b15ce..d2d62f852 100644 --- a/tests/test_felis.py +++ b/tests/test_felis.py @@ -2,11 +2,11 @@ import yaml from pydantic import ValidationError - +from astrodb_utils.loaders import DatabaseSettings from felis.datamodel import Schema -SCHEMA_PATH = "simple/schema.yaml" - +db_settings=DatabaseSettings(settings_file="database.toml") +SCHEMA_PATH = db_settings.felis_path def test_schema(): data = yaml.safe_load(open(SCHEMA_PATH, "r"))