def testXML(self): '''Test XML serialization and re-composition from XML. ''' a = ProfileAttributes('1.3.1.9', '2.0.0', 'profile', 'inactive', 'classified', '1.3.1', ['1.3.1.9.1', '1.3.1.9.2'], 'NASA', ['Updated', 'Created']) doc = xml.dom.minidom.getDOMImplementation().createDocument(None, None, None) node = a.toXML(doc) b = ProfileAttributes(node=node) self.assertEquals(a, b)
def testInstances(self): '''Test to ensure instances don't share instance data. ''' a = ProfileAttributes(id='1') b = ProfileAttributes(id='2') self.assertNotEquals(a, b) a.childIDs.append('3') self.assertNotEquals(a.childIDs, b.childIDs) a.revNotes.append('Uhhhhh, spam?') self.assertNotEquals(a.revNotes, b.revNotes)
def testXMLValidity(self): '''Test to see if all required XML elements are in there. ''' a = ProfileAttributes('1.3.1.9', '2.0.0', 'profile', 'inactive', 'classified', '1.3.1', ['1.3.1.9.1', '1.3.1.9.2'], 'NASA', ['Updated', 'Created']) doc = xml.dom.minidom.getDOMImplementation().createDocument(None, None, None) node = a.toXML(doc) self.assertEquals('profAttributes', node.nodeName) childElements = [n.nodeName for n in node.childNodes] self.assertEquals([u'profId', u'profVersion', u'profType', u'profStatusId', u'profSecurityType', u'profParentId', u'profChildId', u'profChildId', u'profRegAuthority', u'profRevisionNote', u'profRevisionNote'], childElements)
def testCmp(self): '''Test comparison operators. ''' a = ProfileAttributes('1') b = ProfileAttributes('1') c = ProfileAttributes('2') self.assertEquals(a, a) self.assertEquals(a, b) self.assertNotEquals(a, c) self.assert_(a <= a) self.assert_(a <= b) self.assert_(a <= c) self.assert_(a < c)
def testDefaults(self): '''Test to see if default values are reasonable. ''' pa = ProfileAttributes() self.assertEquals('UNKNOWN', pa.id) self.assertEquals('1.0.0', pa.version) self.assertEquals('profile', pa.type) self.assertEquals('active', pa.statusID) self.assertEquals('unclassified', pa.securityType) self.assertEquals('UNKNOWN', pa.parentID) self.assertEquals(0, len(pa.childIDs)) self.assertEquals('UNKNOWN', pa.regAuthority) self.assertEquals(0, len(pa.revNotes))