Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/dir/tests/test_converters.py
Show All 33 Lines | def setUpClass(cls): | ||||
cls.tmpdir = tempfile.mkdtemp(prefix='test-swh-loader-dir.') | cls.tmpdir = tempfile.mkdtemp(prefix='test-swh-loader-dir.') | ||||
@classmethod | @classmethod | ||||
def tearDownClass(cls): | def tearDownClass(cls): | ||||
shutil.rmtree(cls.tmpdir) | shutil.rmtree(cls.tmpdir) | ||||
super().tearDownClass() | super().tearDownClass() | ||||
def test_format_to_minutes(self): | def test_format_to_minutes(self): | ||||
self.assertEquals(converters.format_to_minutes('+0100'), 60) | self.assertEqual(converters.format_to_minutes('+0100'), 60) | ||||
self.assertEquals(converters.format_to_minutes('-0200'), -120) | self.assertEqual(converters.format_to_minutes('-0200'), -120) | ||||
self.assertEquals(converters.format_to_minutes('+1250'), 12*60+50) | self.assertEqual(converters.format_to_minutes('+1250'), 12*60+50) | ||||
self.assertEquals(converters.format_to_minutes('+0000'), 0) | self.assertEqual(converters.format_to_minutes('+0000'), 0) | ||||
self.assertEquals(converters.format_to_minutes('-0000'), 0) | self.assertEqual(converters.format_to_minutes('-0000'), 0) | ||||
def test_annotated_tag_to_release(self): | def test_annotated_tag_to_release(self): | ||||
# given | # given | ||||
release = { | release = { | ||||
'name': 'v0.0.1', | 'name': 'v0.0.1', | ||||
'message': 'synthetic-message-input', | 'message': 'synthetic-message-input', | ||||
'author': {'name': 'author-name', | 'author': {'name': 'author-name', | ||||
'email': 'author-email', | 'email': 'author-email', | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | def test_commit_to_revision(self): | ||||
'synthetic': True, | 'synthetic': True, | ||||
'parents': [] | 'parents': [] | ||||
} | } | ||||
# when | # when | ||||
actual_revision = converters.commit_to_revision(commit) | actual_revision = converters.commit_to_revision(commit) | ||||
# then | # then | ||||
self.assertEquals(actual_revision, expected_revision) | self.assertEqual(actual_revision, expected_revision) | ||||
def test_commit_to_revision_with_parents(self): | def test_commit_to_revision_with_parents(self): | ||||
"""Commit with existing parents should not lose information | """Commit with existing parents should not lose information | ||||
""" | """ | ||||
h = '10041ddb6cbc154c24227b1e8759b81dcd99ea3e' | h = '10041ddb6cbc154c24227b1e8759b81dcd99ea3e' | ||||
# given | # given | ||||
Show All 31 Lines | def test_commit_to_revision_with_parents(self): | ||||
'synthetic': True, | 'synthetic': True, | ||||
'parents': [hashutil.hash_to_bytes(h)] | 'parents': [hashutil.hash_to_bytes(h)] | ||||
} | } | ||||
# when | # when | ||||
actual_revision = converters.commit_to_revision(commit) | actual_revision = converters.commit_to_revision(commit) | ||||
# then | # then | ||||
self.assertEquals(actual_revision, expected_revision) | self.assertEqual(actual_revision, expected_revision) |