Page MenuHomeSoftware Heritage

D2051.diff
No OneTemporary

D2051.diff

diff --git a/swh/objstorage/objstorage.py b/swh/objstorage/objstorage.py
--- a/swh/objstorage/objstorage.py
+++ b/swh/objstorage/objstorage.py
@@ -59,7 +59,7 @@
'lzma': lzma.LZMADecompressor,
'gzip': lambda: zlib.decompressobj(wbits=31),
'zlib': zlib.decompressobj,
- None: NullDecompressor,
+ 'none': NullDecompressor,
}
compressors = {
@@ -67,8 +67,8 @@
'lzma': lzma.LZMACompressor,
'gzip': lambda: zlib.compressobj(wbits=31),
'zlib': zlib.compressobj,
- None: NullCompressor,
- }
+ 'none': NullCompressor,
+}
class ObjStorage(metaclass=abc.ABCMeta):
diff --git a/swh/objstorage/tests/test_objstorage_azure.py b/swh/objstorage/tests/test_objstorage_azure.py
--- a/swh/objstorage/tests/test_objstorage_azure.py
+++ b/swh/objstorage/tests/test_objstorage_azure.py
@@ -7,7 +7,7 @@
from collections import defaultdict
from unittest.mock import patch
-from typing import Any, Dict, Optional
+from typing import Any, Dict
from azure.common import AzureMissingResourceHttpError
from swh.model.hashutil import hash_to_hex
@@ -69,7 +69,7 @@
class TestAzureCloudObjStorage(ObjStorageTestFixture, unittest.TestCase):
- compression = None # type: Optional[str]
+ compression = 'none'
def setUp(self):
super().setUp()
@@ -109,13 +109,13 @@
blob_service._data[container][internal_id] += b'trailing garbage'
- if self.compression is not None:
+ if self.compression == 'none':
with self.assertRaises(Error) as e:
- self.storage.get(obj_id)
- assert 'trailing data' in e.exception.args[0]
+ self.storage.check(obj_id)
else:
with self.assertRaises(Error) as e:
- self.storage.check(obj_id)
+ self.storage.get(obj_id)
+ assert 'trailing data' in e.exception.args[0]
class TestAzureCloudObjStorageGzip(TestAzureCloudObjStorage):
diff --git a/swh/objstorage/tests/test_objstorage_cloud.py b/swh/objstorage/tests/test_objstorage_cloud.py
--- a/swh/objstorage/tests/test_objstorage_cloud.py
+++ b/swh/objstorage/tests/test_objstorage_cloud.py
@@ -8,7 +8,6 @@
from libcloud.common.types import InvalidCredsError
from libcloud.storage.types import (ContainerDoesNotExistError,
ObjectDoesNotExistError)
-from typing import Optional
from swh.model import hashutil
@@ -95,7 +94,7 @@
class TestCloudObjStorage(ObjStorageTestFixture, unittest.TestCase):
- compression = None # type: Optional[str]
+ compression = 'none'
def setUp(self):
super().setUp()
@@ -125,13 +124,13 @@
data[obj_id].content.append(b'trailing garbage')
- if self.compression is not None:
+ if self.compression == 'none':
with self.assertRaises(Error) as e:
- self.storage.get(obj_id)
- assert 'trailing data' in e.exception.args[0]
+ self.storage.check(obj_id)
else:
with self.assertRaises(Error) as e:
- self.storage.check(obj_id)
+ self.storage.get(obj_id)
+ assert 'trailing data' in e.exception.args[0]
class TestCloudObjStorageBz2(TestCloudObjStorage):
diff --git a/swh/objstorage/tests/test_objstorage_pathslicing.py b/swh/objstorage/tests/test_objstorage_pathslicing.py
--- a/swh/objstorage/tests/test_objstorage_pathslicing.py
+++ b/swh/objstorage/tests/test_objstorage_pathslicing.py
@@ -8,8 +8,6 @@
import unittest
from unittest.mock import patch, DEFAULT
-from typing import Optional
-
from swh.model import hashutil
from swh.objstorage import exc, get_objstorage, ID_HASH_LENGTH
@@ -17,7 +15,7 @@
class TestPathSlicingObjStorage(ObjStorageTestFixture, unittest.TestCase):
- compression = None # type: Optional[str]
+ compression = 'none'
def setUp(self):
super().setUp()
@@ -137,7 +135,7 @@
f.write(b'garbage')
with self.assertRaises(exc.Error) as error:
self.storage.check(obj_id)
- if self.compression is None:
+ if self.compression == 'none':
self.assertIn('Corrupt object', error.exception.args[0])
else:
self.assertIn('trailing data found', error.exception.args[0])
diff --git a/swh/objstorage/tests/test_objstorage_seaweedfs.py b/swh/objstorage/tests/test_objstorage_seaweedfs.py
--- a/swh/objstorage/tests/test_objstorage_seaweedfs.py
+++ b/swh/objstorage/tests/test_objstorage_seaweedfs.py
@@ -5,8 +5,6 @@
import unittest
-from typing import Optional
-
from swh.objstorage.objstorage import decompressors
from swh.objstorage.exc import Error
@@ -42,7 +40,7 @@
class TestWeedObjStorage(ObjStorageTestFixture, unittest.TestCase):
- compression = None # type: Optional[str]
+ compression = 'none'
def setUp(self):
super().setUp()
@@ -68,13 +66,13 @@
path = self.storage._path(obj_id)
self.storage.wf.content[path] += b'trailing garbage'
- if self.compression is not None:
+ if self.compression == 'none':
with self.assertRaises(Error) as e:
- self.storage.get(obj_id)
- assert 'trailing data' in e.exception.args[0]
+ self.storage.check(obj_id)
else:
with self.assertRaises(Error) as e:
- self.storage.check(obj_id)
+ self.storage.get(obj_id)
+ assert 'trailing data' in e.exception.args[0]
class TestWeedObjStorageBz2(TestWeedObjStorage):

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 3, 3:44 PM (2 w, 3 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216300

Event Timeline