Skip to content

Commit

Permalink
Merge pull request #7 from zopefoundation/serverzlib-tests
Browse files Browse the repository at this point in the history
Remove ZODB version pin by removing failing test
  • Loading branch information
jimfulton committed Jan 20, 2017
2 parents b1128c5 + 6163fa8 commit 3cd4947
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 29 deletions.
17 changes: 17 additions & 0 deletions .travis.yml
Expand Up @@ -6,9 +6,26 @@ python:
- 3.5
- 3.6
- pypy-5.4.1
env:
matrix:
- ENV=ZODB5
- ENV=ZODB4
matrix:
# Only test ZODB 4 on Python 2.7 (because there are
# some versions of Python 2.7 that cant run ZODB/ZEO 5)
exclude:
- python: 3.4
env: ENV=ZODB4
- python: 3.5
env: ENV=ZODB4
- python: 3.6
env: ENV=ZODB4
- python: pypy-5.4.1
env: ENV=ZODB4
install:
- pip install -U pip setuptools
- pip install -U -e .[test] zope.testrunner
- if [[ $ENV == ZODB4 ]]; then pip uninstall -y ZEO ZODB transaction && pip install "ZODB < 5" "ZEO < 5" "transaction < 2"; fi
script:
- zope-testrunner --test-path=src -v1j99
notifications:
Expand Down
5 changes: 3 additions & 2 deletions CHANGES.rst
Expand Up @@ -7,8 +7,9 @@

- Add support for Python 3.6 and PyPy.

- Restrict ZODB dependency to less than 5.0, and transaction to less
than 2.0. ServerZlibStorage currently doesn't work with ZEO 5.
- Test with both ZODB/ZEO 4 and ZODB/ZEO 5.
Note that ServerZlibStorage cannot be used in a ZODB 5 Connection
(e.g., client-side).
(https://github.com/zopefoundation/zc.zlibstorage/issues/5).

- Close the underlying iterator used by the ``iterator`` wrapper when
Expand Down
14 changes: 12 additions & 2 deletions setup.py
Expand Up @@ -13,8 +13,18 @@
##############################################################################
name, version = 'zc.zlibstorage', '1.1.0'

install_requires = ['setuptools', 'ZODB < 5', 'zope.interface', 'transaction < 2']
extras_require = dict(test=['zope.testing', 'manuel', 'ZEO[test] < 5'])
install_requires = [
'setuptools',
'ZODB',
'zope.interface',
]
extras_require = {
'test': [
'zope.testing',
'manuel',
'ZEO[test]',
]
}

entry_points = """
"""
Expand Down
50 changes: 26 additions & 24 deletions src/zc/zlibstorage/tests.py
Expand Up @@ -208,30 +208,6 @@ def test_mixed_compressed_and_uncompressed_and_packing():
>>> sorted(ZODB.utils.u64(i[0]) for i in record_iter(db.storage))
[0, 2, 3]
>>> db.close()
- using the server storage:
>>> _copy('data.fs', 'data.fs.save')
>>> db = ZODB.DB(zc.zlibstorage.ServerZlibStorage(
... ZODB.FileStorage.FileStorage('data.fs', blob_dir='blobs'),
... compress=False))
>>> db.pack()
>>> sorted(ZODB.utils.u64(i[0]) for i in record_iter(db.storage))
[0, 2, 3]
>>> db.close()
- using the server storage in non-compress mode:
>>> _copy('data.fs', 'data.fs.save')
>>> db = ZODB.DB(zc.zlibstorage.ServerZlibStorage(
... ZODB.FileStorage.FileStorage('data.fs', blob_dir='blobs'),
... compress=False))
>>> db.pack()
>>> sorted(ZODB.utils.u64(i[0]) for i in record_iter(db.storage))
[0, 2, 3]
>>> db.close()
"""

class Dummy:
Expand Down Expand Up @@ -454,6 +430,31 @@ def close(self):
# We can keep closing it though
it.close()

class TestServerZlibStorage(unittest.TestCase):

def test_load_doesnt_decompress(self):
# ServerZlibStorage.load doesn't uncompress the record.
# (This prevents it from being used with a ZODB 5 Connection)
# See https://github.com/zopefoundation/zc.zlibstorage/issues/5
map_store = ZODB.MappingStorage.MappingStorage()
store = zc.zlibstorage.ZlibStorage(map_store)
# Wrap a database to create the root object, and add data to make it
# big enough to compress
db = ZODB.DB(store)
conn = db.open()
conn.root.a = b'x' * 128
transaction.commit()
conn.close()

root_data, _ = store.load(ZODB.utils.z64)
self.assertNotEqual(root_data[:2], b'.z')

server_store = zc.zlibstorage.ServerZlibStorage(map_store)
server_root_data, _ = server_store.load(ZODB.utils.z64)
self.assertEqual(server_root_data[:2], b'.z')

db.close()


def test_suite():
suite = unittest.TestSuite()
Expand All @@ -471,6 +472,7 @@ def test_suite():
suite.addTest(s)

suite.addTest(unittest.makeSuite(TestIterator))
suite.addTest(unittest.makeSuite(TestServerZlibStorage))

# The conflict resolution and blob tests don't exercise proper
# plumbing for zlibstorage because the sample data they use
Expand Down
8 changes: 7 additions & 1 deletion tox.ini
@@ -1,10 +1,16 @@
[tox]
envlist =
py27,py34,py35,py36,pypy
py27,py27-zodb4,py34,py35,py36,pypy

[testenv]
deps =
.[test]
zope.testrunner
commands =
zope-testrunner --test-path=src -v1j99

[testenv:py27-zodb4]
deps =
{[testenv]deps}
ZODB < 5
ZEO < 5

0 comments on commit 3cd4947

Please sign in to comment.