Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed, ZEO5 uses a differenbt internal attribute to store ZEOStorages
- Loading branch information
Jim Fulton
committed
Aug 4, 2016
1 parent
deaa913
commit c2d864f
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |