Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/tests/storage/test_storage.py
Show First 20 Lines • Show All 878 Lines • ▼ Show 20 Lines | def test_content_fossology_license_add__new_license_added(self): | ||||
} | } | ||||
# given | # given | ||||
self.storage.content_fossology_license_add([license_v1]) | self.storage.content_fossology_license_add([license_v1]) | ||||
# conflict does nothing | # conflict does nothing | ||||
self.storage.content_fossology_license_add([license_v1]) | self.storage.content_fossology_license_add([license_v1]) | ||||
# when | # when | ||||
actual_licenses = list(self.storage.content_fossology_license_get( | actual_licenses = self.storage.content_fossology_license_get( | ||||
[self.sha1_1])) | [self.sha1_1]) | ||||
# then | # then | ||||
expected_license = { | expected_license = { | ||||
self.sha1_1: [{ | self.sha1_1: [{ | ||||
'licenses': ['Apache-2.0'], | 'licenses': ['Apache-2.0'], | ||||
'tool': tool, | 'tool': tool, | ||||
}] | }] | ||||
} | } | ||||
self.assertEqual(actual_licenses, [expected_license]) | self.assertEqual(actual_licenses, expected_license) | ||||
# given | # given | ||||
license_v2 = license_v1.copy() | license_v2 = license_v1.copy() | ||||
license_v2.update({ | license_v2.update({ | ||||
'licenses': ['BSD-2-Clause'], | 'licenses': ['BSD-2-Clause'], | ||||
}) | }) | ||||
self.storage.content_fossology_license_add([license_v2]) | self.storage.content_fossology_license_add([license_v2]) | ||||
actual_licenses = list(self.storage.content_fossology_license_get( | actual_licenses = self.storage.content_fossology_license_get( | ||||
[self.sha1_1])) | [self.sha1_1]) | ||||
expected_license = { | expected_license = { | ||||
self.sha1_1: [{ | self.sha1_1: [{ | ||||
'licenses': ['Apache-2.0', 'BSD-2-Clause'], | 'licenses': ['Apache-2.0', 'BSD-2-Clause'], | ||||
'tool': tool | 'tool': tool | ||||
}] | }] | ||||
} | } | ||||
# license did not change as the v2 was dropped. | # license did not change as the v2 was dropped. | ||||
self.assertEqual(actual_licenses, [expected_license]) | self.assertEqual(actual_licenses, expected_license) | ||||
# content_metadata tests | # content_metadata tests | ||||
( | ( | ||||
test_content_metadata_missing, | test_content_metadata_missing, | ||||
test_content_metadata_add__drop_duplicate, | test_content_metadata_add__drop_duplicate, | ||||
test_content_metadata_add__update_in_place_duplicate, | test_content_metadata_add__update_in_place_duplicate, | ||||
test_content_metadata_add__update_in_place_deadlock, | test_content_metadata_add__update_in_place_deadlock, | ||||
test_content_metadata_add__duplicate_twice, | test_content_metadata_add__duplicate_twice, | ||||
▲ Show 20 Lines • Show All 1,061 Lines • Show Last 20 Lines |