Skip to content

Commit 9780ec4

Browse files
connierwest
authored andcommitted
Add work in progress parent-child relationship unittest to databaseTest
1 parent d5fca81 commit 9780ec4

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

databaseTest.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,28 @@ def test_kinetics_checkGroupsNonidentical(self):
7272
del entriesCopy[nodeName]
7373
for nodeNameOther, nodeGroupOther in entriesCopy.iteritems():
7474
self.assertFalse(family.matchNodeToNode(nodeGroup, nodeGroupOther), "Group {group} in {family} family was found to be identical to group {groupOther}".format(group=nodeName, family=family_name, groupOther=nodeNameOther))
75-
76-
75+
76+
@work_in_progress
77+
def test_kinetics_checkChildParentRelationships(self):
78+
"""
79+
This test checks that groups' parent-child relationships are correct in the database.
80+
"""
81+
from rmgpy.data.base import Database
82+
for family_name, originalFamily in self.database.kinetics.families.iteritems():
83+
family = Database()
84+
family.entries = originalFamily.groups.entries
85+
entriesCopy = copy(family.entries)
86+
for nodeName, nodeGroup in family.entries.iteritems():
87+
ascendParent = nodeGroup
88+
# Check whether the node has proper parents unless it is the top reactant or product node
89+
while ascendParent not in originalFamily.groups.top and ascendParent not in originalFamily.forwardTemplate.products:
90+
child = ascendParent
91+
ascendParent = ascendParent.parent
92+
# The parent should be more general than the child
93+
self.assertTrue(family.matchNodeToChild(ascendParent,child),
94+
"In {family} family, group {parent} is not a proper parent of its child {child}.".format(family=family_name, parent=ascendParent, child=child))
95+
96+
7797

7898
if __name__ == '__main__':
7999
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))

0 commit comments

Comments
 (0)