Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_storage.py
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | def cmpdir(directory): | ||||
return (directory['type'], directory['dir_id']) | return (directory['type'], directory['dir_id']) | ||||
def short_revision(revision): | def short_revision(revision): | ||||
return [revision['id'], revision['parents']] | return [revision['id'], revision['parents']] | ||||
class TestStorage: | class TestStorage: | ||||
"""Base class for Storage testing. | """Main class for Storage testing. | ||||
This class is used as-is to test local storage (see TestLocalStorage | This class is used as-is to test local storage (see TestLocalStorage | ||||
below) and remote storage (see TestRemoteStorage in | below) and remote storage (see TestRemoteStorage in | ||||
test_remote_storage.py. | test_remote_storage.py. | ||||
We need to have the two classes inherit from this base class | We need to have the two classes inherit from this base class | ||||
separately to avoid nosetests running the tests from the base | separately to avoid nosetests running the tests from the base | ||||
class twice. | class twice. | ||||
▲ Show 20 Lines • Show All 2,903 Lines • ▼ Show 20 Lines | def test_origin_metadata_get_by_provider_type(self, swh_storage): | ||||
'tool_id': tool['id'] | 'tool_id': tool['id'] | ||||
}] | }] | ||||
# then | # then | ||||
assert len(m_by_provider) == 1 | assert len(m_by_provider) == 1 | ||||
assert m_by_provider == expected_results | assert m_by_provider == expected_results | ||||
class TestStorageCommonProp: | class TestStorageGeneratedData: | ||||
_test_origin_ids = True | _test_origin_ids = True | ||||
def assert_contents_ok(self, expected_contents, actual_contents, | def assert_contents_ok(self, expected_contents, actual_contents, | ||||
keys_to_check={'sha1', 'data'}): | keys_to_check={'sha1', 'data'}): | ||||
"""Assert that a given list of contents matches on a given set of keys. | """Assert that a given list of contents matches on a given set of keys. | ||||
""" | """ | ||||
for k in keys_to_check: | for k in keys_to_check: | ||||
▲ Show 20 Lines • Show All 501 Lines • Show Last 20 Lines |