From 5b157dc3ef0ca6f696bbdfe64092511dd91f04cf Mon Sep 17 00:00:00 2001 From: Heet Jani Date: Wed, 23 Sep 2026 13:14:09 -0500 Subject: [PATCH] [test] add existing accession to collection object --- .../tests/test_collectionobject.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/specifyweb/backend/businessrules/tests/test_collectionobject.py b/specifyweb/backend/businessrules/tests/test_collectionobject.py index 9e231a924d4..5710554ea5c 100644 --- a/specifyweb/backend/businessrules/tests/test_collectionobject.py +++ b/specifyweb/backend/businessrules/tests/test_collectionobject.py @@ -3,6 +3,7 @@ Collectionobject, Collectionobjecttype, Component, + Accession, ) from specifyweb.specify.tests.test_api import ApiTests from specifyweb.backend.businessrules.tests.test_component import enable_unique_catnum_pref @@ -31,6 +32,22 @@ def test_catalog_number_unique_in_collection(self): catalognumber=self.collectionobjects[0].catalognumber + 'foo') test_co.delete() + def test_add_existing_accession_to_collectionobject(self): + accession = Accession.objects.create( + accessionnumber="Test Accession", + division=self.division, + ) + + collection_object = Collectionobject.objects.create( + collection=self.collection, + accession=accession, + ) + + fetched_object = Collectionobject.objects.get(id=collection_object.id) + self.assertEqual(fetched_object.accession, accession) + self.assertEqual(fetched_object.accession.accessionnumber, "Test Accession") + + def test_default_collectionobjecttype(self): default_type = Collectionobjecttype.objects.create( name="default type",