def testDependency(self): """ Test to see if dependent parcels are correctly loaded """ self.manager.path.append(os.path.join(self.testdir,'dependencyparcels')) self.loadParcel("http://testparcels.org/parcels/depA") self.rep.commit() # Ensure depA Parcel was created with the right Kind and attrs depA = self.rep.findPath("//parcels/application/tests/dependencyparcels/depA") self.assertEqual(depA.itsKind, Parcel.getKind(self.rep)) # Ensure testKind was created with the right Kind testKind = self.rep.findPath("//parcels/application/tests/dependencyparcels/depA/TestKind") self.assertEqual(testKind.itsKind, self.rep.findPath('//Schema/Core/Kind')) # Ensure depB Parcel was created with the right Kind and attrs depB = self.rep.findPath("//parcels/application/tests/dependencyparcels/depB") self.assertEqual(depB.itsKind, Parcel.getKind(self.rep)) # Ensure depC Parcel was created with the right Kind and attrs depC = self.rep.findPath("//parcels/application/tests/dependencyparcels/depB/depC") self.assertEqual(depC.itsKind, Parcel.getKind(self.rep)) # Ensure testAttribute was created with the right Kind testAttribute = self.rep.findPath("//parcels/application/tests/dependencyparcels/depB/depC/TestAttribute") self.assertEqual(testAttribute.itsKind, self.rep.findPath('//Schema/Core/Attribute')) # Ensure testAttribute is an attribute of testKind (and vice-versa) self.assert_(testKind.attributes.has_key(testAttribute.itsUUID)) self.assert_(testAttribute.kinds.has_key(testKind.itsUUID))
def testItems(self): """ Ensure we can create items within a parcel file """ self.manager.path.append(os.path.join(self.testdir, "itemparcels")) self.loadParcels(["http://testparcels.org/items", "http://testparcels.org/super"]) # Ensure the Parcel was created parcel = self.rep.findPath("//parcels/application/tests/itemparcels/items") self.assertEqual(parcel.itsKind, Parcel.getKind(self.rep)) # Ensure testInstances were created testInstance1 = self.rep.findPath("//parcels/application/tests/itemparcels/items/TestInstance1") self.assertEqual( testInstance1.itsKind, self.rep.findPath("//parcels/application/tests/itemparcels/items/Kind2") ) testInstance2 = self.rep.findPath("//parcels/application/tests/itemparcels/items/TestInstance2") self.assertEqual( testInstance2.itsKind, self.rep.findPath("//parcels/application/tests/itemparcels/items/Kind2") ) self.assertEqual(testInstance1.RefAttribute, testInstance2) self.assertEqual(testInstance1.StringAttribute, "XYZZY") self.assertEqual(testInstance1.EnumAttribute, "B") kind1 = self.rep.findPath("//parcels/application/tests/itemparcels/super/Kind1") self.assert_(kind1) kind2 = self.rep.findPath("//parcels/application/tests/itemparcels/items/Kind2") self.assert_(kind2) self.assert_(kind1 in kind2.superKinds) self.assert_(kind2 in kind1.subKinds)
def testLoadParcels(self): """ Load all parcels beneath testparcels directory and then check to make sure the repository contains what we expect. """ self.manager.path.append(os.path.join(self.testdir, "testparcels")) self.loadParcel("parcel:application.tests.testparcels.simple.data") self.rep.commit() # Ensure the simple Parcel was created with the right Kind and attrs simpleParcel = self.rep.findPath("//parcels/application/tests/testparcels/simple") self.assertEqual(simpleParcel.itsKind, Parcel.getKind(self.rep)) self.assertEqual(simpleParcel.displayName, "Simple Parcel") self.assertEqual(simpleParcel.description, "Simple Parcel Loader Test Schema") self.assertEqual(simpleParcel.version, "0.1") self.assertEqual(simpleParcel.author, "Open Source Applications Foundation") # Ensure testAttribute was created with the right Kind and attrs testAttribute = self.rep.findPath("//parcels/application/tests/testparcels/simple/TestAttribute") self.assertEqual(testAttribute.itsKind, self.rep.findPath("//Schema/Core/Attribute")) self.assertEqual(testAttribute.type, self.rep.findPath("//Schema/Core/String")) self.assertEqual(testAttribute.displayName, "Test Attribute") self.assertEqual(testAttribute.cardinality, "single") # Ensure testKind was created with the right Kind and attrs testKind = self.rep.findPath("//parcels/application/tests/testparcels/simple/TestKind") self.assertEqual(testKind.itsKind, self.rep.findPath("//Schema/Core/Kind")) self.assertEqual(testKind.displayName, "Test Kind") self.assertEqual(testKind.displayAttribute, "TestAttribute") # Ensure testAttribute is an attribute of testKind (and vice-versa) self.assert_(testKind.attributes.has_key(testAttribute.itsUUID)) self.assert_(testAttribute.kinds.has_key(testKind.itsUUID)) # Ensure subKind was created with the right Kind and attrs subKind = self.rep.findPath("//parcels/application/tests/testparcels/simple/SubKind") self.assertEqual(subKind.itsKind, self.rep.findPath("//Schema/Core/Kind")) self.assertEqual(subKind.displayName, "Subclass Test Kind") # Ensure testKind and subKind have the correct inheritence links self.assert_(subKind.superKinds.has_key(testKind.itsUUID)) self.assert_(testKind.subKinds.has_key(subKind.itsUUID)) # Ensure that an empty defaultValue for a list attribute gets # sets properly # item1 = self.rep.findPath("//parcels/application/tests/testparcels/simple/data/item1") # Ensure that initialValue for a list/dict attributes are # set properly item3 = self.rep.findPath("//parcels/application/tests/testparcels/simple/data/item3") self.assertEqual(type(item3.ListAttribute).__name__, "PersistentList") self.assertEqual(type(item3.DictAttribute).__name__, "PersistentDict") # make sure this attribute isn't readonly: item3.ListAttribute.append("foo") # make sure an initialValue was set correctly: self.assert_(item3.TestAttribute == "XYZZY")
def testDependency(self): """ Test to see if dependent parcels are correctly loaded """ self.manager.path.append( os.path.join(self.testdir, 'dependencyparcels')) self.loadParcel("http://testparcels.org/parcels/depA") self.rep.commit() # Ensure depA Parcel was created with the right Kind and attrs depA = self.rep.findPath( "//parcels/application/tests/dependencyparcels/depA") self.assertEqual(depA.itsKind, Parcel.getKind(self.rep)) # Ensure testKind was created with the right Kind testKind = self.rep.findPath( "//parcels/application/tests/dependencyparcels/depA/TestKind") self.assertEqual(testKind.itsKind, self.rep.findPath('//Schema/Core/Kind')) # Ensure depB Parcel was created with the right Kind and attrs depB = self.rep.findPath( "//parcels/application/tests/dependencyparcels/depB") self.assertEqual(depB.itsKind, Parcel.getKind(self.rep)) # Ensure depC Parcel was created with the right Kind and attrs depC = self.rep.findPath( "//parcels/application/tests/dependencyparcels/depB/depC") self.assertEqual(depC.itsKind, Parcel.getKind(self.rep)) # Ensure testAttribute was created with the right Kind testAttribute = self.rep.findPath( "//parcels/application/tests/dependencyparcels/depB/depC/TestAttribute" ) self.assertEqual(testAttribute.itsKind, self.rep.findPath('//Schema/Core/Attribute')) # Ensure testAttribute is an attribute of testKind (and vice-versa) self.assert_(testKind.attributes.has_key(testAttribute.itsUUID)) self.assert_(testAttribute.kinds.has_key(testKind.itsUUID))
def testItems(self): """ Ensure we can create items within a parcel file """ self.manager.path.append(os.path.join(self.testdir, 'itemparcels')) self.loadParcels( ["http://testparcels.org/items", "http://testparcels.org/super"]) # Ensure the Parcel was created parcel = self.rep.findPath( "//parcels/application/tests/itemparcels/items") self.assertEqual(parcel.itsKind, Parcel.getKind(self.rep)) # Ensure testInstances were created testInstance1 = self.rep.findPath( "//parcels/application/tests/itemparcels/items/TestInstance1") self.assertEqual( testInstance1.itsKind, self.rep.findPath( "//parcels/application/tests/itemparcels/items/Kind2")) testInstance2 = self.rep.findPath( "//parcels/application/tests/itemparcels/items/TestInstance2") self.assertEqual( testInstance2.itsKind, self.rep.findPath( "//parcels/application/tests/itemparcels/items/Kind2")) self.assertEqual(testInstance1.RefAttribute, testInstance2) self.assertEqual(testInstance1.StringAttribute, "XYZZY") self.assertEqual(testInstance1.EnumAttribute, "B") kind1 = self.rep.findPath( "//parcels/application/tests/itemparcels/super/Kind1") self.assert_(kind1) kind2 = self.rep.findPath( "//parcels/application/tests/itemparcels/items/Kind2") self.assert_(kind2) self.assert_(kind1 in kind2.superKinds) self.assert_(kind2 in kind1.subKinds)
def testLoadParcels(self): """ Load all parcels beneath testparcels directory and then check to make sure the repository contains what we expect. """ self.manager.path.append(os.path.join(self.testdir, 'testparcels')) self.loadParcel("parcel:application.tests.testparcels.simple.data") self.rep.commit() # Ensure the simple Parcel was created with the right Kind and attrs simpleParcel = self.rep.findPath( "//parcels/application/tests/testparcels/simple") self.assertEqual(simpleParcel.itsKind, Parcel.getKind(self.rep)) self.assertEqual(simpleParcel.displayName, "Simple Parcel") self.assertEqual(simpleParcel.description, "Simple Parcel Loader Test Schema") self.assertEqual(simpleParcel.version, "0.1") self.assertEqual(simpleParcel.author, "Open Source Applications Foundation") # Ensure testAttribute was created with the right Kind and attrs testAttribute = self.rep.findPath( "//parcels/application/tests/testparcels/simple/TestAttribute") self.assertEqual(testAttribute.itsKind, self.rep.findPath('//Schema/Core/Attribute')) self.assertEqual(testAttribute.type, self.rep.findPath('//Schema/Core/String')) self.assertEqual(testAttribute.displayName, "Test Attribute") self.assertEqual(testAttribute.cardinality, "single") # Ensure testKind was created with the right Kind and attrs testKind = self.rep.findPath( "//parcels/application/tests/testparcels/simple/TestKind") self.assertEqual(testKind.itsKind, self.rep.findPath('//Schema/Core/Kind')) self.assertEqual(testKind.displayName, "Test Kind") self.assertEqual(testKind.displayAttribute, "TestAttribute") # Ensure testAttribute is an attribute of testKind (and vice-versa) self.assert_(testKind.attributes.has_key(testAttribute.itsUUID)) self.assert_(testAttribute.kinds.has_key(testKind.itsUUID)) # Ensure subKind was created with the right Kind and attrs subKind = self.rep.findPath( "//parcels/application/tests/testparcels/simple/SubKind") self.assertEqual(subKind.itsKind, self.rep.findPath('//Schema/Core/Kind')) self.assertEqual(subKind.displayName, "Subclass Test Kind") # Ensure testKind and subKind have the correct inheritence links self.assert_(subKind.superKinds.has_key(testKind.itsUUID)) self.assert_(testKind.subKinds.has_key(subKind.itsUUID)) # Ensure that an empty defaultValue for a list attribute gets # sets properly # item1 = self.rep.findPath("//parcels/application/tests/testparcels/simple/data/item1") # Ensure that initialValue for a list/dict attributes are # set properly item3 = self.rep.findPath( "//parcels/application/tests/testparcels/simple/data/item3") self.assertEqual(type(item3.ListAttribute).__name__, "PersistentList") self.assertEqual(type(item3.DictAttribute).__name__, "PersistentDict") # make sure this attribute isn't readonly: item3.ListAttribute.append("foo") # make sure an initialValue was set correctly: self.assert_(item3.TestAttribute == "XYZZY")