-
Notifications
You must be signed in to change notification settings - Fork 1
/
testScript.py
88 lines (63 loc) · 2.72 KB
/
testScript.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from __future__ import with_statement
import unittest
from EADBWrapper import EADBWrapper, SysMLObject, SysMLObjectList
class SysMLObjectTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.dbo = EADBWrapper()
def test_initialization(self):
obj = SysMLObject()
obj.getData(self.dbo, 385412)
self.assertTrue(385407 in obj.daughters)
self.assertTrue(385394 in obj.daughters)
self.assertTrue(385385 in obj.daughters)
self.assertTrue(385340 in obj.daughters)
self.assertTrue(385362 in obj.daughters)
class EADBWrapperTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.dbo = EADBWrapper()
def test_many_options(self):
"""
Make sure that an exception is raised if more than one object
match the name you give
"""
with self.assertRaises(RuntimeError) as context:
familyTree = self.dbo.getFamilyIDs('g-band Response Envelope')
self.assertEqual(context.exception.args[0],
'More than one object match the name you gave. '
'Try specifying an author or a version')
def test_no_options(self):
"""
Make sure that an exception is raise if no objects are returned.
"""
with self.assertRaises(RuntimeError) as context:
familyTree = self.dbo.getFamilyIDs('blah blah blah')
self.assertEqual(context.exception.args[0],
'No objects matched the name you gave.')
def test_g_band_daughters(self):
"""
Make sure that we get the full inheritance tree of
g-band Response Envelope
This verifies that things I 'know' are correct get returned
as daughters (i.e. things that are in Chuck's example diagram)
It does not verify the length of 'daughters' (if something
that is not in Chuck's diagram is in the inheritance tree,
that still shows up)
"""
daughters = self.dbo.getFamilyIDs('g-band Response Envelope',
author='Chuck Claver')
self.assertTrue(385412 in daughters)
self.assertTrue(385333 in daughters)
self.assertTrue(385376 in daughters)
self.assertTrue(385394 in daughters)
self.assertTrue(385385 in daughters)
self.assertTrue(385362 in daughters)
self.assertTrue(385340 in daughters)
def test_list(self):
daughters = self.dbo.getFamilyIDs('g-band Response Envelope',
author='Chuck Claver')
objList = SysMLObjectList(self.dbo, daughters)
print objList._relationship_dict
if __name__ == "__main__":
unittest.main()