Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/tests/test_loader.py
Show First 20 Lines • Show All 614 Lines • ▼ Show 20 Lines | def process_repository(self): | ||||
'99c27ebbd43feca179ac0e895af131d8314cafe1': '3397ca7f709639cbd36b18a0d1b70bce80018c45', # noqa | '99c27ebbd43feca179ac0e895af131d8314cafe1': '3397ca7f709639cbd36b18a0d1b70bce80018c45', # noqa | ||||
'902f29b4323a9b9de3af6d28e72dd581e76d9397': 'c4e12483f0a13e6851459295a4ae735eb4e4b5c4', # noqa | '902f29b4323a9b9de3af6d28e72dd581e76d9397': 'c4e12483f0a13e6851459295a4ae735eb4e4b5c4', # noqa | ||||
last_revision: 'fd24a76c87a3207428e06612b49860fc78e9f6dc' # noqa | last_revision: 'fd24a76c87a3207428e06612b49860fc78e9f6dc' # noqa | ||||
} | } | ||||
self.assertRevisionsOk(expected_revisions) | self.assertRevisionsOk(expected_revisions) | ||||
class SWHSvnLoaderUpdateAndTestCornerCasesAboutEolITTest(BaseTestSvnLoader): | class SWHSvnLoaderTestCornerCaseAboutCrlfEolInRepoITTest(BaseTestSvnLoader): | ||||
""" | |||||
Check that a svn repo containing a versioned file with CRLF line | |||||
endings with svn:eol-style property set to 'native' (this is | |||||
a violation of svn specification as the file should have been | |||||
stored with LF line endings) can be loaded anyway. | |||||
""" | |||||
def setUp(self): | def setUp(self): | ||||
super().setUp(archive_name='pkg-gourmet-with-eol-corner-cases.tgz') | super().setUp(archive_name='mediawiki-repo-r407-eol-native-crlf.tgz', | ||||
filename='mediawiki-repo-r407-eol-native-crlf') | |||||
self.origin = {'id': 2, 'type': 'svn', 'url': 'file:///dev/null'} | self.origin = {'id': 1, 'type': 'svn', | ||||
'url': 'https://code.google.com/p/pyang/pyang-repo'} | |||||
self.origin_visit = { | self.origin_visit = { | ||||
'origin': self.origin['id'], | 'origin': self.origin['id'], | ||||
'visit': 1, | 'visit': 1, | ||||
} | } | ||||
self.loader = SWHSvnLoaderUpdateLessRecentNoStorage() | self.loader = SWHSvnLoaderNoStorage() | ||||
self.loader.prepare( | self.loader.prepare( | ||||
self.svn_mirror_url, self.destination_path, self.origin) | self.svn_mirror_url, self.destination_path, self.origin) | ||||
@istest | @istest | ||||
def process_repository(self): | def process_repository(self): | ||||
"""EOL corner cases and update. | |||||
""" | """ | ||||
previous_unfinished_revision = { | Process repository with CRLF line endings and svn:eol-style set to 'native' | ||||
'id': hashutil.hash_to_bytes( | """ # noqa | ||||
'171dc35522bfd17dda4e90a542a0377fb2fc707a'), | # when | ||||
'parents': [hashutil.hash_to_bytes( | self.loader.process_repository(self.origin_visit) | ||||
'902f29b4323a9b9de3af6d28e72dd581e76d9397')], | |||||
'directory': hashutil.hash_to_bytes( | expected_revisions = { | ||||
'fd24a76c87a3207428e06612b49860fc78e9f6dc'), | '7da4975c363101b819756d33459f30a866d01b1b': 'f63637223ee0f7d4951ffd2d4d9547a4882c5d8b' # noqa | ||||
'target_type': 'revision', | |||||
'metadata': { | |||||
'extra_headers': [ | |||||
['svn_repo_uuid', '3187e211-bb14-4c82-9596-0b59d67cd7f4'], | |||||
['svn_revision', '11'] | |||||
] | |||||
} | |||||
} | } | ||||
# when | self.assertRevisionsOk(expected_revisions) | ||||
self.loader.process_repository( | |||||
self.origin_visit, | |||||
last_known_swh_revision=previous_unfinished_revision) | |||||
# then | |||||
# we got the previous run's last revision (rev 11) | |||||
# so 8 new | |||||
self.assertEquals(len(self.loader.all_revisions), 8) | |||||
self.assertEquals(len(self.loader.all_releases), 0) | |||||
last_revision = '0148ae3eaa520b73a50802c59f3f416b7a36cf8c' | class SWHSvnLoaderTestCornerCaseAboutMixedCrlfLfEolInRepoITTest(BaseTestSvnLoader): # noqa | ||||
""" | |||||
Check that a svn repo containing a versioned file with mixed | |||||
CRLF/LF line endings with svn:eol-style property set to 'native' | |||||
(this is a violation of svn specification as mixed line endings | |||||
for textual content should not be stored when the svn:eol-style | |||||
property is set) can be loaded anyway. | |||||
""" | |||||
def setUp(self): | |||||
super().setUp(archive_name='pyang-repo-r343-eol-native-mixed-lf-crlf.tgz', # noqa | |||||
filename='pyang-repo-r343-eol-native-mixed-lf-crlf') | |||||
self.origin = {'id': 1, 'type': 'svn', | |||||
'url': 'https://code.google.com/m/mediawiki/mediawiki-repo'} # noqa | |||||
self.origin_visit = { | |||||
'origin': self.origin['id'], | |||||
'visit': 1, | |||||
} | |||||
self.loader = SWHSvnLoaderNoStorage() | |||||
self.loader.prepare( | |||||
self.svn_mirror_url, self.destination_path, self.origin) | |||||
@istest | |||||
def process_repository(self): | |||||
""" | |||||
Process repository with mixed CRLF/LF line endings and svn:eol-style set to 'native' | |||||
""" # noqa | |||||
self.loader.process_repository(self.origin_visit) | |||||
# cf. test_loader.org for explaining from where those hashes | |||||
# come from | |||||
expected_revisions = { | expected_revisions = { | ||||
# revision hash | directory hash | '9c6962eeb9164a636c374be700672355e34a98a7': '16aa6b6271f3456d4643999d234cf39fe3d0cc5a' # noqa | ||||
'027e8769f4786597436ab94a91f85527d04a6cbb': '2d9ca72c6afec6284fb01e459588cbb007017c8c', # noqa | |||||
'4474d96018877742d9697d5c76666c9693353bfc': 'ab111577e0ab39e4a157c476072af48f2641d93f', # noqa | |||||
'97ad21eab92961e2a22ca0285f09c6d1e9a7ffbc': 'ab111577e0ab39e4a157c476072af48f2641d93f', # noqa | |||||
'd04ea8afcee6205cc8384c091bfc578931c169fd': 'b0a648b02e55a4dce356ac35187a058f89694ec7', # noqa | |||||
'ded78810401fd354ffe894aa4a1e5c7d30a645d1': 'b0a648b02e55a4dce356ac35187a058f89694ec7', # noqa | |||||
'4ee95e39358712f53c4fc720da3fafee9249ed19': 'c3c98df624733fef4e592bef983f93e2ed02b179', # noqa | |||||
'ffa901b69ca0f46a2261f42948838d19709cb9f8': 'c3c98df624733fef4e592bef983f93e2ed02b179', # noqa | |||||
last_revision: '844d4646d6c2b4f3a3b2b22ab0ee38c7df07bab2', # noqa | |||||
} | } | ||||
self.assertRevisionsOk(expected_revisions) | self.assertRevisionsOk(expected_revisions) | ||||
class SWHSvnLoaderExternalIdCornerCaseITTest(BaseTestSvnLoader): | class SWHSvnLoaderExternalIdCornerCaseITTest(BaseTestSvnLoader): | ||||
def setUp(self): | def setUp(self): | ||||
super().setUp(archive_name='pkg-gourmet-with-external-id.tgz') | super().setUp(archive_name='pkg-gourmet-with-external-id.tgz') | ||||
▲ Show 20 Lines • Show All 198 Lines • Show Last 20 Lines |