[Zope-CVS] CVS: Products/Ape/lib/apelib/tests - testio.py:1.2
Shane Hathaway
shane@zope.com
Mon, 26 May 2003 22:19:14 -0400
Update of /cvs-repository/Products/Ape/lib/apelib/tests
In directory cvs.zope.org:/tmp/cvs-serv3480/tests
Modified Files:
testio.py
Log Message:
Expanded the ExportImport test and fixed a bug in import. It was only
possible to import one object, which is exactly what the former test did.
=== Products/Ape/lib/apelib/tests/testio.py 1.1 => 1.2 ===
--- Products/Ape/lib/apelib/tests/testio.py:1.1 Mon May 26 15:33:16 2003
+++ Products/Ape/lib/apelib/tests/testio.py Mon May 26 22:19:13 2003
@@ -51,9 +51,6 @@
def getKeyedObjectSystem(self):
return TestKeyedObjectSystem()
- def getMapper(self):
- return self.root_mapper
-
def testImpl(self):
# Test of test :-)
from Interface.Verify import verifyClass
@@ -66,7 +63,7 @@
ob['c'] = 'd'
keychain = ('test',)
kos = self.getKeyedObjectSystem()
- obsys = io.ObjectSystemIO(self.getMapper(), kos)
+ obsys = io.ObjectSystemIO(self.root_mapper, kos)
event, classified_state = obsys.serialize(keychain, ob)
ob2 = obsys.newObject(classified_state)
@@ -83,8 +80,8 @@
ob['c'] = 'd'
keychain = ('test',)
kos = self.getKeyedObjectSystem()
- obsys = io.ObjectSystemIO(self.getMapper(), kos)
- gwsys = io.GatewayIO(self.getMapper(), self.conns)
+ obsys = io.ObjectSystemIO(self.root_mapper, kos)
+ gwsys = io.GatewayIO(self.root_mapper, self.conns)
event, classified_state = obsys.serialize(keychain, ob)
gwsys.store(keychain, classified_state)
@@ -96,19 +93,32 @@
def testExportImport(self):
- ob = PersistentMapping()
- ob.strdata = '345'
- ob['a'] = 'b'
- ob['c'] = 'd'
- keychain = ('test',)
- exporter = io.ExportImport(self.getMapper(), self.conns)
- exporter.exportObject(ob, keychain)
+ root = PersistentMapping()
- importer = io.ExportImport(self.getMapper(), self.conns)
- ob2 = importer.importObject(keychain)
- self.assert_(ob is not ob2)
- self.assertEqual(ob, ob2)
- self.assertEqual(ob.strdata, ob2.strdata)
+ test1 = PersistentMapping()
+ test1.strdata = '345'
+ test1['a'] = 'b'
+ test1['c'] = 'd'
+ root['TestRoot'] = test1
+ test2 = PersistentMapping()
+ test2.leftover = 'oops'
+ test2['true'] = 'undecided'
+ root['TestRoot2'] = test2
+
+ keychain = ()
+ exporter = io.ExportImport(self.root_mapper, self.conns)
+ exporter.exportObject(root, keychain)
+
+ importer = io.ExportImport(self.root_mapper, self.conns)
+ roota = importer.importObject(keychain)
+ self.assert_(root is not roota)
+ self.assert_(root['TestRoot'] is not roota['TestRoot'])
+ self.assert_(root['TestRoot2'] is not roota['TestRoot2'])
+ self.assertEqual(root['TestRoot'], roota['TestRoot'])
+ self.assertEqual(root['TestRoot2'], roota['TestRoot2'])
+ self.assertEqual(root['TestRoot'].strdata, roota['TestRoot'].strdata)
+ self.assertEqual(root['TestRoot2'].leftover,
+ roota['TestRoot2'].leftover)