Skip to content

Commit

Permalink
✅ Test rm of cascade delete on biospecimen
Browse files Browse the repository at this point in the history
  • Loading branch information
znatty22 committed Feb 28, 2024
1 parent 9bc2200 commit 68975d9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/sample/test_sample_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,21 @@ def test_create_sample(self):

def test_delete_sample(self):
"""
Test that a sample and its biospecimens are removed
Test that a sample and its biospecimen's sample_id is set to null
"""
s = make_sample()
make_biospecimen(
b = make_biospecimen(
external_sample_id="c1", sample=s, force_create=True
)
bs_kf_id = b.kf_id
sample = Sample.query.filter_by(external_id=s.external_id).one()
db.session.delete(sample)
db.session.commit()

assert Sample.query.count() == 0
assert Biospecimen.query.count() == 0
assert Biospecimen.query.count() == 1

assert Biospecimen.query.get(bs_kf_id).sample_id is None

def test_delete_sample_orphan(self):
"""
Expand Down

0 comments on commit 68975d9

Please sign in to comment.