Skip to content

Commit 6d2c89a

Browse files
ying2212kelle
andauthored
Reorganize to use database.toml (#682)
* add database.toml file * update path in test files + move schema path * update conftest to use build_db_from_json * Update tests/conftest.py Co-authored-by: Kelle Cruz <kellecruz@gmail.com> Co-authored-by: Kelle Cruz <kellecruz@gmail.com>
1 parent 2f4db75 commit 6d2c89a

5 files changed

Lines changed: 22 additions & 25 deletions

File tree

data/reference/Versions.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@
185185
"end_date": "2026-04-14",
186186
"description": "Spectra provided by BONES Archive"
187187
},
188+
{
189+
"version": "5.4.2026.02",
190+
"start_date": "2026-04-14",
191+
"end_date": "2026-04-14",
192+
"description": "Add database.toml"
193+
},
188194
{
189195
"version": "latest",
190196
"start_date": "2026-04-14",
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
db_name = "simple_tests"
2+
data_path = "data/"
3+
felis_path = "schema.yaml"
14

2-
REFERENCE_TABLES = [
5+
lookup_tables = [
36
"Publications",
47
"Telescopes",
58
"Instruments",
9+
"Parameters",
610
"PhotometryFilters",
711
"Versions",
8-
"Parameters",
912
"RegimeList",
10-
"CompanionList"
11-
]
13+
"CompanionList",
14+
]
File renamed without changes.

tests/conftest.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,22 @@
33
import sys
44

55
import pytest
6-
from astrodb_utils import load_astrodb
6+
from astrodb_utils.loaders import build_db_from_json, DatabaseSettings
77
from astrodbkit.astrodb import Database, create_database
88

99
sys.path.append("./") # needed for github actions to find the simple module
10-
from simple import REFERENCE_TABLES
1110

1211
logger = logging.getLogger("AstroDB")
1312

14-
SCHEMA_PATH = "simple/schema.yaml"
15-
13+
db_settings=DatabaseSettings(settings_file="database.toml")
14+
SCHEMA_PATH = db_settings.felis_path
1615

1716
# Create a fresh SIMPLE database for the data and integrity tests
1817
@pytest.fixture(scope="session", autouse=True)
1918
def db():
20-
DB_NAME = "tests/simple_tests.sqlite"
21-
DB_PATH = "data"
22-
23-
if os.path.exists(DB_NAME):
24-
os.remove(DB_NAME)
25-
connection_string = "sqlite:///" + DB_NAME
26-
create_database(connection_string, felis_schema=SCHEMA_PATH)
27-
assert os.path.exists(DB_NAME)
28-
29-
# Connect to the new database
30-
db = load_astrodb(DB_NAME,
31-
data_path=DB_PATH,
32-
reference_tables=REFERENCE_TABLES,
33-
felis_schema=SCHEMA_PATH)
19+
db = build_db_from_json(
20+
settings_file="database.toml"
21+
)
3422

3523
return db
3624

tests/test_felis.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import yaml
44
from pydantic import ValidationError
5-
5+
from astrodb_utils.loaders import DatabaseSettings
66
from felis.datamodel import Schema
77

8-
SCHEMA_PATH = "simple/schema.yaml"
9-
8+
db_settings=DatabaseSettings(settings_file="database.toml")
9+
SCHEMA_PATH = db_settings.felis_path
1010

1111
def test_schema():
1212
data = yaml.safe_load(open(SCHEMA_PATH, "r"))

0 commit comments

Comments
 (0)