diff --git a/swh/storage/tests/test_api_client.py b/swh/storage/tests/test_api_client.py --- a/swh/storage/tests/test_api_client.py +++ b/swh/storage/tests/test_api_client.py @@ -11,12 +11,12 @@ from swh.core.tests.server_testing import ServerTestFixture from swh.storage.api.client import RemoteStorage from swh.storage.api.server import app -from swh.storage.tests.test_storage import CommonTestStorage, \ - StorageTestDbFixture +from swh.storage.tests.test_storage import \ + CommonTestStorage, CommonPropTestStorage, StorageTestDbFixture -class TestRemoteStorage(CommonTestStorage, ServerTestFixture, - StorageTestDbFixture, unittest.TestCase): +class RemoteStorageFixture(ServerTestFixture, StorageTestDbFixture, + unittest.TestCase): """Test the remote storage API. This class doesn't define any tests as we want identical @@ -55,6 +55,15 @@ super().tearDown() shutil.rmtree(self.storage_base) + +@pytest.mark.db +class TestRemoteStorage(CommonTestStorage, RemoteStorageFixture): @pytest.mark.skip('refresh_stat_counters not available in the remote api.') def test_stat_counters(self): pass + + +@pytest.mark.db +@pytest.mark.property_based +class PropTestRemoteStorage(CommonPropTestStorage, RemoteStorageFixture): + pass 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 @@ -8,7 +8,8 @@ from swh.storage.in_memory import Storage -from swh.storage.tests.test_storage import CommonTestStorage +from swh.storage.tests.test_storage import \ + CommonTestStorage, CommonPropTestStorage class TestInMemoryStorage(CommonTestStorage, unittest.TestCase): @@ -29,3 +30,33 @@ @pytest.mark.skip('postgresql-specific test') def test_skipped_content_add(self): pass + + +@pytest.mark.db +@pytest.mark.property_based +class PropTestInMemoryStorage(CommonPropTestStorage, 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. + """ + def setUp(self): + super().setUp() + self.storage = Storage() + + @pytest.mark.xfail(reason='not implemented yet') + def test_generate_content_get(self): + super().test_generate_content_get() + + @pytest.mark.xfail(reason='not implemented yet') + def test_generate_content_get_range_limit_none(self): + super().test_generate_content_get_range_limit_none() + + @pytest.mark.xfail(reason='not implemented yet') + def test_generate_content_get_range_no_limit(self): + super().test_generate_content_get_range_no_limit() + + @pytest.mark.xfail(reason='not implemented yet') + def test_generate_content_get_range_limit(self): + super().test_generate_content_get_range_limit() diff --git a/swh/storage/tests/test_storage.py b/swh/storage/tests/test_storage.py --- a/swh/storage/tests/test_storage.py +++ b/swh/storage/tests/test_storage.py @@ -1850,9 +1850,7 @@ self.assertEqual(m_by_provider, expected_results) -@pytest.mark.db -@pytest.mark.property_based -class PropBasedTestStorage(StorageTestDbFixture, unittest.TestCase): +class CommonPropTestStorage: def assert_contents_ok(self, expected_contents, actual_contents, keys_to_check={'sha1', 'data'}): """Assert that a given list of contents matches on a given set of keys. @@ -1972,6 +1970,7 @@ keys_to_check) +@pytest.mark.db class TestLocalStorage(CommonTestStorage, StorageTestDbFixture, unittest.TestCase): """Test the local storage""" @@ -2052,6 +2051,13 @@ self.assertEqual(missing, [self.cont['sha1']]) +@pytest.mark.db +@pytest.mark.property_based +class PropTestLocalStorage(CommonPropTestStorage, StorageTestDbFixture, + unittest.TestCase): + pass + + class AlteringSchemaTest(TestStorageData, StorageTestDbFixture, unittest.TestCase): """This class is dedicated for the rare case where the schema needs to