[Zodb-checkins] CVS: StandaloneZODB/ZEO/tests - testZEO.py:1.16.4.4.2.15

Shane Hathaway shane@cvs.zope.org
Mon, 10 Jun 2002 18:04:52 -0400


Update of /cvs-repository/StandaloneZODB/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv13120/tests

Modified Files:
      Tag: ZEO2-branch
	testZEO.py 
Log Message:
Added a test that ensures ZEO invalidation messages get sent and received.
This currently fails; in a moment I will check in the fix.

Also cleaned up a test and the test framework invocation.


=== StandaloneZODB/ZEO/tests/testZEO.py 1.16.4.4.2.14 => 1.16.4.4.2.15 ===
         self._dostore(data=obj)
 
+    def checkZEOInvalidation(self):
+        addr = self._storage._rpc_mgr.addr[0][1]
+        storage2 = ZEO.ClientStorage.ClientStorage(addr, wait=1,
+                                                   min_disconnect_poll=0.1)
+        try:
+            oid = self._storage.new_oid()
+            ob = MinPO('first')
+            revid1 = self._dostore(oid, data=ob)
+            data, serial = storage2.load(oid, '')
+            self.assertEqual(zodb_unpickle(data), MinPO('first'))
+            self.assertEqual(serial, revid1)
+            revid2 = self._dostore(oid, data=MinPO('second'), revid=revid1)
+            for n in range(3):
+                # Let the server and client talk for a moment.
+                # Is there a better way to do this?
+                asyncore.poll(0.1)
+            data, serial = storage2.load(oid, '')
+            self.assertEqual(zodb_unpickle(data), MinPO('second'),
+                             'Invalidation message was not sent!')
+            self.assertEqual(serial, revid2)
+        finally:
+            storage2.close()
+
+
 class ZEOFileStorageTests(GenericTests):
     __super_setUp = GenericTests.setUp
 
@@ -297,8 +321,8 @@
         self.shutdownServer()
         self._storage = self.openClientStorage('test', 100000, wait=0)
         data, revid2 = self._storage.load(oid, '')
-        assert zodb_unpickle(data) == MinPO(12)
-        assert revid1 == revid2
+        self.assertEqual(zodb_unpickle(data), MinPO(12))
+        self.assertEqual(revid1, revid2)
         self._storage.close()
 
     def checkRollover(self):
@@ -413,23 +437,5 @@
         suite.addTest(sub)
     return suite
 
-def main():
-    import sys, getopt
-
-    name_of_test = ''
-
-    opts, args = getopt.getopt(sys.argv[1:], 'n:')
-    for flag, val in opts:
-        if flag == '-n':
-            name_of_test = val
-
-    if args:
-        print "Did not expect arguments.  Got %s" % args
-        return 0
-
-    tests = makeTestSuite(name_of_test)
-    runner = unittest.TextTestRunner()
-    runner.run(tests)
-
 if __name__ == "__main__":
-    main()
+    unittest.main(defaultTest='test_suite')