~ubuntu-branches/ubuntu/quantal/zodb/quantal

« back to all changes in this revision

Viewing changes to src/ZEO/tests/testZEO.py

  • Committer: Bazaar Package Importer
  • Author(s): Fabio Tranchitella, Brian Sutherland, Fabio Tranchitella
  • Date: 2010-01-05 22:22:35 UTC
  • mfrom: (6.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100105222235-z2xg4h60ru3e891t
Tags: 1:3.9.4-1
[ Brian Sutherland ]
* debian/tests/all: Test the correct python modules.

[ Fabio Tranchitella ]
* New upstream release.
* Convert to debhelper 7 and the pydeb dh7 extension.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
 
53
53
logger = logging.getLogger('ZEO.tests.testZEO')
54
54
 
 
55
ZEO.zrpc.connection.start_client_thread()
 
56
 
55
57
class DummyDB:
56
58
    def invalidate(self, *args):
57
59
        pass
436
438
                     > client_timeout_count)
437
439
 
438
440
 
439
 
class CatastrophicClientLoopFailure(
440
 
    ZEO.tests.ConnectionTests.CommonSetupTearDown):
441
 
    """Test what happens when the client loop falls over
442
 
    """
 
441
class ZRPCConnectionTests(ZEO.tests.ConnectionTests.CommonSetupTearDown):
443
442
 
444
443
    def getConfig(self, path, create, read_only):
445
444
        return """<mappingstorage 1/>"""
446
445
 
447
446
    def checkCatastrophicClientLoopFailure(self):
 
447
        # Test what happens when the client loop falls over
448
448
        self._storage = self.openClientStorage()
449
449
 
450
450
        class Evil:
472
472
        self.assertEqual(log[1][0], "Couldn't close a dispatcher.")
473
473
        self.assert_('exc_info' in log[1][1])
474
474
 
475
 
class ConnectionInvalidationOnReconnect(
476
 
    ZEO.tests.ConnectionTests.CommonSetupTearDown):
477
 
    """Test what happens when the client loop falls over
478
 
    """
 
475
    def checkExceptionLogsAtError(self):
 
476
        # Test the exceptions are logged at error
 
477
        self._storage = self.openClientStorage()
 
478
        conn = self._storage._connection
 
479
        # capture logging
 
480
        log = []
 
481
        conn.logger.log = (
 
482
            lambda l, m, *a, **kw: log.append((l,m % a, kw))
 
483
            )
479
484
 
480
 
    def getConfig(self, path, create, read_only):
481
 
        return """<mappingstorage 1/>"""
 
485
        # This is a deliberately bogus call to get an exception
 
486
        # logged
 
487
        self._storage._connection.handle_request('foo',0,'history',(1,2,3,4))
 
488
        # test logging
 
489
        level,message,kw = log[1]
 
490
        self.assertEqual(level,logging.ERROR)
 
491
        self.failUnless(message.endswith(
 
492
                ') history() raised exception: history() takes at'
 
493
                ' most 3 arguments (5 given)'
 
494
                ))
 
495
        self.assertEqual(kw,{'exc_info':True})
 
496
        
 
497
        # cleanup
 
498
        del conn.logger.log
482
499
 
483
500
    def checkConnectionInvalidationOnReconnect(self):
484
501
 
1214
1231
 
1215
1232
quick_test_classes = [
1216
1233
    FileStorageRecoveryTests, ConfigurationTests, HeartbeatTests,
1217
 
    CatastrophicClientLoopFailure, ConnectionInvalidationOnReconnect,
 
1234
    ZRPCConnectionTests,
1218
1235
    ]
1219
1236
 
1220
1237
class ServerManagingClientStorage(ClientStorage):