Commit fec86e26 authored by Julien Muchembled's avatar Julien Muchembled

fixup! Add support for custom compression levels

parent 0c34630c
......@@ -14,7 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from functools import partial
import zlib
decompress_list = (
......@@ -40,7 +39,8 @@ def getCompress(value):
alg, level = (0, None) if value is True else value
_compress = zlib.compress
if level:
_compress = partial(_compress, level=level)
zlib_compress = _compress
_compress = lambda data: zlib_compress(data, level)
alg += 1
assert 0 < alg < len(decompress_list), 'invalid compression algorithm'
def compress(data):
......
......@@ -55,8 +55,8 @@ class ConfigTests(NEOThreadedTest):
for kw['compress'] in '9', 'best', 'zlib=0', 'zlib=100':
self.assertRaises(ConfigurationSyntaxError, databaseFromDict, **kw)
for compress in valid:
with self._db(cluster, compress=compress):
pass
with self._db(cluster, compress=compress) as db:
self.assertEqual((0,0,''), db.storage.app.compress(''))
if __name__ == "__main__":
unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment