Skip to content

Commit 50272d3

Browse files
authored
Update test_helpers.py
SynBioDex#69 test cases
1 parent 9720930 commit 50272d3

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/test_helpers.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import unittest
22
import os
33
from pathlib import Path
4+
import sbol3
5+
import tyto
46

57
from sbol_utilities import component
68

@@ -31,6 +33,36 @@ def test_url_sanitization(self):
3133
self.assertEqual(strip_filetype_suffix('http://foo/bar/baz.gb'), 'http://foo/bar/baz')
3234
self.assertEqual(strip_filetype_suffix('http://foo/bar/baz.qux'), 'http://foo/bar/baz.qux')
3335

36+
def test_is_composite(self):
37+
"""Test the is_composite function."""
38+
# Set up a test SBOL document and namespace
39+
doc = sbol3.Document()
40+
sbol3.set_namespace('http://sbolstandard.org/test')
41+
# Case 1: Valid composite component (Has DNA type + Assembly Plan)
42+
comp1 = sbol3.Component('comp1', types=[tyto.SO.DNA])
43+
assembly_activity = sbol3.Activity('activity1')
44+
assembly_activity.types.append("http://sbols.org/v3#assemblyPlan")
45+
assembly_activity.types.append(sbol3.SBOL_DESIGN)
46+
# Add activity to the document
47+
doc.add(assembly_activity)
48+
comp1.generated_by.append(sbol3.ReferencedObject(assembly_activity.identity))
49+
doc.add(comp1)
50+
self.assertTrue(is_composite(comp1), "Expected comp1 to be composite")
51+
# Case 2: Not composite (No DNA type, but has Assembly Plan)
52+
comp2 = sbol3.Component('comp2', types=[tyto.SO.RNA]) # RNA type instead of DNA
53+
comp2.generated_by.append(sbol3.ReferencedObject(assembly_activity.identity))
54+
doc.add(comp2)
55+
self.assertFalse(is_composite(comp2), "Expected comp2 to NOT be composite")
56+
# Case 3: Not composite (Has DNA type, but no Assembly Plan)
57+
comp3 = sbol3.Component('comp3', types=[tyto.SO.DNA])
58+
doc.add(comp3)
59+
self.assertFalse(is_composite(comp3), "Expected comp3 to NOT be composite")
60+
# Case 4: Not composite (No DNA type, No Assembly Plan)
61+
comp4 = sbol3.Component('comp4', types=[tyto.SO.RNA])
62+
doc.add(comp4)
63+
self.assertFalse(is_composite(comp4), "Expected comp4 to NOT be composite")
64+
65+
3466
def test_filtering_top_level_objects(self):
3567
"""Check filtering Top Level Objects by a condition"""
3668
test_dir = os.path.dirname(os.path.realpath(__file__))

0 commit comments

Comments
 (0)