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

« back to all changes in this revision

Viewing changes to src/ZEO/tests/testConversionSupport.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:
91
91
 
92
92
The client simply delegates record_iternext calls to it's server stub.
93
93
 
94
 
There's really no decent way to test ZEO without running to muc crazy
95
 
stuff.  I'd rather to a lame test than a really lame test, so here goes.
 
94
There's really no decent way to test ZEO without running too much crazy
 
95
stuff.  I'd rather do a lame test than a really lame test, so here goes.
96
96
 
97
97
First, fake out the connection manager so we can make a connection:
98
98
 
108
108
    >>> client = ClientStorage('', wait=False)
109
109
    >>> ClientStorage.ConnectionManagerClass = oldConnectionManagerClass
110
110
 
111
 
Now we'll have our way with it's provate _server attr:
 
111
Now we'll have our way with it's private _server attr:
112
112
 
113
113
    >>> client._server = FakeStorage()
114
114
    >>> next = None
129
129
 
130
130
The server stub simply delegates record_iternext calls to it's rpc.
131
131
 
132
 
There's really no decent way to test ZEO without running to muc crazy
133
 
stuff.  I'd rather to a lame test than a really lame test, so here goes.
 
132
There's really no decent way to test ZEO without running to much crazy
 
133
stuff.  I'd rather do a lame test than a really lame test, so here goes.
134
134
 
135
135
    >>> class FauxRPC:
136
136
    ...     storage = FakeStorage()
153
153
 
154
154
"""
155
155
    
 
156
def history_to_version_compatible_storage():
 
157
    """
 
158
    Some storages work under ZODB <= 3.8 and ZODB >= 3.9.
 
159
    This means they have a history method that accepts a version parameter:
 
160
 
 
161
    >>> class VersionCompatibleStorage(FakeStorageBase):
 
162
    ...   def history(self,oid,version='',size=1):
 
163
    ...     return oid,version,size
 
164
 
 
165
    A ZEOStorage such as the following should support this type of storage:
 
166
    
 
167
    >>> class OurFakeServer(FakeServer):
 
168
    ...   storages = {'1':VersionCompatibleStorage()}
 
169
    >>> import ZEO.StorageServer
 
170
    >>> zeo = ZEO.StorageServer.ZEOStorage(OurFakeServer(), False)
 
171
    >>> zeo.register('1', False)
 
172
 
 
173
    The ZEOStorage should sort out the following call such that the storage gets
 
174
    the correct parameters and so should return the parameters it was called with:
 
175
 
 
176
    >>> zeo.history('oid',99)
 
177
    ('oid', '', 99)
 
178
 
 
179
    The same problem occurs when a Z308 client connects to a Z309 server,
 
180
    but different code is executed:
 
181
 
 
182
    >>> from ZEO.StorageServer import ZEOStorage308Adapter
 
183
    >>> zeo = ZEOStorage308Adapter(VersionCompatibleStorage())
 
184
    
 
185
    The history method should still return the parameters it was called with:
 
186
 
 
187
    >>> zeo.history('oid','',99)
 
188
    ('oid', '', 99)
 
189
    """
 
190
 
156
191
def test_suite():
157
192
    return doctest.DocTestSuite()
158
193