| | 105 | class TestNameProperty(BaseTestdObject): |
|---|
| | 106 | """ |
|---|
| | 107 | Test List: |
|---|
| | 108 | - Set dObject.Name to n. dObject.Name should be equal to n. (round trip test) |
|---|
| | 109 | - dObject.Name should return '?' if no name is assigned |
|---|
| | 110 | - dObject.Name should fail when given a non-string input |
|---|
| | 111 | """ |
|---|
| | 112 | |
|---|
| | 113 | def testRoundTrip(self): |
|---|
| | 114 | """Set dObject.Name to n. dObject.Name should be equal to n. (round trip test)""" |
|---|
| | 115 | self.dObject.Name = "Test Name" |
|---|
| | 116 | self.assertEqual("Test Name", self.dObject.Name) |
|---|
| | 117 | |
|---|
| | 118 | def testNoNameSet(self): |
|---|
| | 119 | """dObject.Name should return '?' if no name is assigned""" |
|---|
| | 120 | self.assertEqual('?', self.dObject.Name) |
|---|
| | 121 | |
|---|
| | 122 | def testFailOnNonStringInput(self): |
|---|
| | 123 | """dObject.Name should fail when given a non-string input""" |
|---|
| | 124 | def setName(val): |
|---|
| | 125 | self.dObject.Name = val |
|---|
| | 126 | self.assertRaises(TypeError, setName, 42) |
|---|
| | 127 | |
|---|
| | 128 | class TestParentProperty(BaseTestdObject): |
|---|
| | 129 | """ |
|---|
| | 130 | Test List: |
|---|
| | 131 | - Set dObject.Parent to n. dObject.Parent should be equal to n. (round trip test) |
|---|
| | 132 | - dObject.Parent should return None if there is no parent |
|---|
| | 133 | """ |
|---|
| | 134 | |
|---|
| | 135 | def testRoundTrip(self): |
|---|
| | 136 | """Set dObject.Parent to n. dObject.Parent should be equal to n. (round trip test)""" |
|---|
| | 137 | test = dObject() |
|---|
| | 138 | test.Parent = self.dObject |
|---|
| | 139 | self.assertEqual(test.Parent, self.dObject) |
|---|
| | 140 | |
|---|
| | 141 | def testNoParentSet(self): |
|---|
| | 142 | """dObject.Parent should return None if there is no parent""" |
|---|
| | 143 | self.assertEqual(self.dObject.Parent, None) |
|---|
| | 144 | |
|---|
| | 145 | class TestPreferenceManagerProperty(BaseTestdObject): |
|---|
| | 146 | """ |
|---|
| | 147 | Test List: |
|---|
| | 148 | - Set dObject.PreferenceManager to n. dObject.PreferenceManagier should be equal to n. (round trip test) |
|---|
| | 149 | - dObject.PreferenceManager should fail when set to an object not of type dPref |
|---|
| | 150 | - initial conditon test??? |
|---|
| | 151 | """ |
|---|
| | 152 | |
|---|
| | 153 | def testRoundTrip(self): |
|---|
| | 154 | """Set dObject.PreferenceManager to n. dObject.PreferenceManagier should be equal to n. (round trip test)""" |
|---|
| | 155 | from dabo.dPref import dPref |
|---|
| | 156 | testDPref = dPref() |
|---|
| | 157 | self.dObject.PreferenceManager = testDPref |
|---|
| | 158 | self.assertEqual(testDPref, self.dObject.PreferenceManager) |
|---|
| | 159 | |
|---|
| | 160 | def testSetFailOnNondPrefValue(self): |
|---|
| | 161 | """dObject.PreferenceManager should fail when set to an object not of type dPref""" |
|---|
| | 162 | def setPreferenceManager(val): |
|---|
| | 163 | self.dObject.PreferenceManager = val |
|---|
| | 164 | self.assertRaises(TypeError, setPreferenceManager, 42) |
|---|
| | 165 | |
|---|
| | 166 | #TODO: NEED A TEST HERE FOR INITIAL CONDITION |
|---|
| | 167 | |
|---|
| | 168 | class TestSuperClassProperty(BaseTestdObject): |
|---|
| | 169 | """ |
|---|
| | 170 | Test List: |
|---|
| | 171 | - Set dObject.SuperClass should fail with any input |
|---|
| | 172 | - a.SuperClass should return class Dummy when a = dObject() |
|---|
| | 173 | - a.SuperClass should return class dObject when a = someObject and someObject subclasses dObject |
|---|
| | 174 | """ |
|---|
| | 175 | |
|---|
| | 176 | def testSetAlwaysFails(self): |
|---|
| | 177 | """Set dObject.SuperClass should fail with any input""" |
|---|
| | 178 | def setSuperClass(val): |
|---|
| | 179 | self.dObject.SuperClass = val |
|---|
| | 180 | self.assertRaises(AttributeError, setSuperClass, 42) |
|---|
| | 181 | self.assertRaises(AttributeError, setSuperClass, "string") |
|---|
| | 182 | self.assertRaises(AttributeError, setSuperClass, ("tuple", 12, 23)) |
|---|
| | 183 | self.assertRaises(AttributeError, setSuperClass, dObject) |
|---|
| | 184 | self.assertRaises(AttributeError, setSuperClass, Dummy) |
|---|
| | 185 | |
|---|
| | 186 | def testGetNoSubclass(self): |
|---|
| | 187 | """a.SuperClass should return class Dummy when a = dObject()""" |
|---|
| | 188 | self.assertEqual(Dummy, self.dObject.SuperClass) |
|---|
| | 189 | |
|---|
| | 190 | def testGetWithSubclass(self): |
|---|
| | 191 | """a.SuperClass should return class dObject when a = someObject and someObject subclasses dObject""" |
|---|
| | 192 | class someObject(dObject): |
|---|
| | 193 | pass |
|---|
| | 194 | a = someObject() |
|---|
| | 195 | self.assertEqual(dObject, a.SuperClass) |
|---|
| | 196 | |
|---|