Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_storage.py
Show First 20 Lines • Show All 2,214 Lines • ▼ Show 20 Lines | def test_origin_get_range(self, new_origins): | ||||
self.assertEqual(len(origins), origin_count) | self.assertEqual(len(origins), origin_count) | ||||
origin_from = 10000 | origin_from = 10000 | ||||
origins = list( | origins = list( | ||||
self.storage.origin_get_range(origin_from=origin_from, | self.storage.origin_get_range(origin_from=origin_from, | ||||
origin_count=origin_count)) | origin_count=origin_count)) | ||||
self.assertEqual(len(origins), 0) | self.assertEqual(len(origins), 0) | ||||
def test_origin_count(self): | |||||
new_origins = [ | |||||
{ | |||||
'type': 'git', | |||||
'url': 'https://github.com/user1/repo1' | |||||
}, | |||||
{ | |||||
'type': 'git', | |||||
'url': 'https://github.com/user2/repo1' | |||||
}, | |||||
{ | |||||
'type': 'git', | |||||
'url': 'https://github.com/user3/repo1' | |||||
}, | |||||
{ | |||||
'type': 'git', | |||||
'url': 'https://gitlab.com/user1/repo1' | |||||
}, | |||||
{ | |||||
'type': 'git', | |||||
'url': 'https://gitlab.com/user2/repo1' | |||||
} | |||||
] | |||||
self.storage.origin_add(new_origins) | |||||
self.assertEqual(self.storage.origin_count('github'), 3) | |||||
self.assertEqual(self.storage.origin_count('gitlab'), 2) | |||||
self.assertEqual( | |||||
self.storage.origin_count('.*user.*', regexp=True), 5) | |||||
self.assertEqual( | |||||
self.storage.origin_count('.*user.*', regexp=False), 0) | |||||
vlorentz: Should have a test with `regexp=False` too | |||||
Done Inline Actionsack anlambert: ack | |||||
self.assertEqual( | |||||
self.storage.origin_count('.*user1.*', regexp=True), 2) | |||||
self.assertEqual( | |||||
self.storage.origin_count('.*user1.*', regexp=False), 0) | |||||
@pytest.mark.db | @pytest.mark.db | ||||
class TestLocalStorage(CommonTestStorage, StorageTestDbFixture, | class TestLocalStorage(CommonTestStorage, StorageTestDbFixture, | ||||
unittest.TestCase): | unittest.TestCase): | ||||
"""Test the local storage""" | """Test the local storage""" | ||||
# Can only be tested with local storage as you can't mock | # Can only be tested with local storage as you can't mock | ||||
# datetimes for the remote server | # datetimes for the remote server | ||||
▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines |
Should have a test with regexp=False too