Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
gtfierro committed Feb 18, 2025
1 parent 84aa275 commit e1415a7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Generates tests automatically
"""

import glob
from pathlib import Path

Expand Down
24 changes: 17 additions & 7 deletions tests/unit/database/test_cascading_deletes_cascades.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pytest
from buildingmotif.dataclasses.template import Template

from buildingmotif.database.errors import (
LibraryNotFound,
TemplateNotFound,
ModelNotFound,
ShapeCollectionNotFound,
TemplateNotFound,
)
from buildingmotif.dataclasses.template import Template


def test_cascade_delete_model_shape_collection(bm):
# Create a model; its manifest (shape collection) should be cascading deleted.
Expand All @@ -25,8 +26,12 @@ def test_cascade_delete_library_cascades(bm):
# Create a library, two templates within it, and a dependency relationship.
db_library = bm.table_connection.create_db_library(name="cascade_library")
shape_collection_id = db_library.shape_collection.id
template1 = bm.table_connection.create_db_template(name="template1", library_id=db_library.id)
template2 = bm.table_connection.create_db_template(name="template2", library_id=db_library.id)
template1 = bm.table_connection.create_db_template(
name="template1", library_id=db_library.id
)
template2 = bm.table_connection.create_db_template(
name="template2", library_id=db_library.id
)

# Add a dependency relationship between template1 and template2.
template1 = Template.load(template1.id)
Expand All @@ -48,13 +53,18 @@ def test_cascade_delete_library_cascades(bm):
with pytest.raises(ShapeCollectionNotFound):
bm.table_connection.get_db_shape_collection(shape_collection_id)


def test_cascade_delete_multi_library(bm):
# Create two libraries
library1 = bm.table_connection.create_db_library(name="cascade_library1")
library2 = bm.table_connection.create_db_library(name="cascade_library2")
# Create template1 in library1 and template2 in library2
template1 = bm.table_connection.create_db_template(name="template1", library_id=library1.id)
template2 = bm.table_connection.create_db_template(name="template2", library_id=library2.id)
template1 = bm.table_connection.create_db_template(
name="template1", library_id=library1.id
)
template2 = bm.table_connection.create_db_template(
name="template2", library_id=library2.id
)
# Load templates to add dependency and verify dependency relationship.
template1 = Template.load(template1.id)
template2 = Template.load(template2.id)
Expand Down

0 comments on commit e1415a7

Please sign in to comment.