Skip to content

Commit

Permalink
fixed, ZEO5 uses a differenbt internal attribute to store ZEOStorages
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Fulton committed Aug 4, 2016
1 parent deaa913 commit c2d864f
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/ZEO/tests/test_sync.py
@@ -0,0 +1,49 @@
import unittest

from zope.testing import setupstack

from .. import server, client

from . import forker

if forker.ZEO4_SERVER:
server_ping_method = 'lastTransaction'
server_zss = 'connections'
else:
server_ping_method = 'ping'
server_zss = 'zeo_storages_by_storage_id'

class SyncTests(setupstack.TestCase):

def instrument(self):
self.__ping_calls = 0

server = getattr(forker, self.__name + '_server')

[zs] = getattr(server.server, server_zss)['1']
orig_ping = getattr(zs, server_ping_method)
def ping():
self.__ping_calls += 1
return orig_ping()

setattr(zs, server_ping_method, ping)

def test_server_sync(self):
self.__name = 's%s' % id(self)
addr, stop = server(name=self.__name)

# By default the client sync method is a noop:
c = client(addr)
self.instrument()
c.sync()
self.assertEqual(self.__ping_calls, 0)
c.close()

# But if we pass server_sync:
c = client(addr, server_sync=True)
self.instrument()
c.sync()
self.assertEqual(self.__ping_calls, 1)
c.close()

stop()

0 comments on commit c2d864f

Please sign in to comment.