Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sierra-moxon committed Jan 10, 2025
1 parent c6b202c commit 59f159a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 3 additions & 2 deletions schema_automator/importers/dbml_import_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ def convert(
processed_slots = set() # Track processed slot names to avoid duplicates

# Handle primary key and unique constraints
primary_key_columns = [col for col in table.columns if col.primary_key]
unique_columns = [col for col in table.columns if col.unique and not col.primary_key]
primary_key_columns = [col for col in table.columns if col.pk]
unique_columns = [col for col in table.columns if col.unique and not col.pk]
# multi_column_unique_keys = table.indexes # Assuming `indexes` captures multi-column unique keys

# Process columns
for column in table.columns:

slot_name = column.name
slot_def = SlotDefinition(
name=slot_name,
Expand Down
7 changes: 2 additions & 5 deletions tests/test_importers/test_dbml_importer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from pathlib import Path
from linkml_runtime.linkml_model import SchemaDefinition, ClassDefinition, SlotDefinition, EnumDefinition
from schema_automator.importers.dbml_import_engine import DbmlImportEngine # Replace with actual module name
from schema_automator.importers.dbml_import_engine import DbmlImportEngine

# Sample DBML content for testing
DBML_SAMPLE = """
Expand All @@ -16,7 +16,6 @@
user_id int [not null]
product_id int [not null]
quantity int
index [unique, order_id, user_id]
}
Table Countries {
Expand All @@ -32,6 +31,7 @@ def dbml_file(tmp_path):
"""
dbml_path = tmp_path / "test.dbml"
dbml_path.write_text(DBML_SAMPLE)
print(dbml_path)
return dbml_path

@pytest.fixture
Expand Down Expand Up @@ -59,9 +59,6 @@ def test_dbml_to_linkml_conversion(dbml_file, importer):
assert schema.slots["id"].identifier
assert schema.slots["id"].required

# Check unique keys
orders_class = schema.classes["Orders"]
assert orders_class.unique_keys == [["order_id", "user_id"]]

def test_controlled_vocabulary_detection(dbml_file, importer):
"""
Expand Down

0 comments on commit 59f159a

Please sign in to comment.