Page MenuHomeSoftware Heritage

D2095.id7208.diff
No OneTemporary

D2095.id7208.diff

diff --git a/swh/storage/in_memory.py b/swh/storage/in_memory.py
--- a/swh/storage/in_memory.py
+++ b/swh/storage/in_memory.py
@@ -81,10 +81,10 @@
content.status = 'visible'
if content.length is None:
content.length = -1
- if content.status == 'visible':
+ if content.status != 'absent':
if self._content_key(content) not in self._contents:
content_with_data.append(content)
- elif content.status == 'absent':
+ else:
if self._content_key(content) not in self._skipped_contents:
content_without_data.append(content)
diff --git a/swh/storage/tests/test_in_memory.py b/swh/storage/tests/test_in_memory.py
--- a/swh/storage/tests/test_in_memory.py
+++ b/swh/storage/tests/test_in_memory.py
@@ -2,80 +2,32 @@
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
-import unittest
import pytest
-from swh.storage.in_memory import Storage, ENABLE_ORIGIN_IDS
+from swh.storage import get_storage
+from swh.storage.tests.test_storage import ( # noqa
+ TestStorage, TestStorageGeneratedData)
+from swh.storage.in_memory import ENABLE_ORIGIN_IDS
-from swh.storage.tests.test_storage import (
- TestStorage as _TestStorage,
- TestStorageGeneratedData as _TestStorageCommonProp)
+TestStorage._test_origin_ids = ENABLE_ORIGIN_IDS
+TestStorageGeneratedData._test_origin_ids = ENABLE_ORIGIN_IDS
-@pytest.mark.xfail
-class TestInMemoryStorage(_TestStorage, unittest.TestCase):
- """Test the in-memory storage API
- This class doesn't define any tests as we want identical
- functionality between local and remote storage. All the tests are
- therefore defined in CommonTestStorage.
- """
- _test_origin_ids = ENABLE_ORIGIN_IDS
+# tests are executed using imported classes (TestStorage and
+# TestStorageGeneratedData) using overloaded swh_storage fixture
+# below
- def setUp(self):
- super().setUp()
- self.reset_storage()
-
- @pytest.mark.skip('postgresql-specific test')
- def test_content_add_db(self):
- pass
-
- @pytest.mark.skip('postgresql-specific test')
- def test_skipped_content_add_db(self):
- pass
-
- @pytest.mark.skip('postgresql-specific test')
- def test_content_add_metadata_db(self):
- pass
-
- if not _test_origin_ids:
- @pytest.mark.skip('requires origin ids')
- def test_origin_metadata_add(self):
- pass
-
- @pytest.mark.skip('requires origin ids')
- def test_origin_metadata_get(self):
- pass
-
- @pytest.mark.skip('requires origin ids')
- def test_origin_metadata_get_by_provider_type(self):
- pass
-
- def reset_storage(self):
- self.storage = Storage(journal_writer={'cls': 'memory'})
- self.journal_writer = self.storage.journal_writer
-
-
-@pytest.mark.xfail
-@pytest.mark.property_based
-class PropTestInMemoryStorage(_TestStorageCommonProp, unittest.TestCase):
- """Test the in-memory storage API
-
- This class doesn't define any tests as we want identical
- functionality between local and remote storage. All the tests are
- therefore defined in CommonPropTestStorage.
- """
- _test_origin_ids = ENABLE_ORIGIN_IDS
-
- def setUp(self):
- super().setUp()
- self.storage = Storage()
-
- def reset_storage(self):
- self.storage = Storage()
-
- if not _test_origin_ids:
- @pytest.mark.skip('requires origin ids')
- def test_origin_get_range(self, new_origins):
- pass
+@pytest.fixture
+def swh_storage():
+ storage_config = {
+ 'cls': 'memory',
+ 'args': {
+ 'journal_writer': {
+ 'cls': 'memory',
+ },
+ },
+ }
+ storage = get_storage(**storage_config)
+ return storage

File Metadata

Mime Type
text/plain
Expires
Nov 5 2024, 2:58 PM (12 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3220728

Event Timeline