def test_does_not_overwrite_existing_entry(self): image = make_image_spec() total_resources = set_resource(resource="Original resource", image_spec=image) original_resources = total_resources.mapping.copy() resources_from_repo = set_resource(resource="New resource", image_spec=image) download_descriptions.boot_merge(total_resources, resources_from_repo) self.assertEqual(original_resources, total_resources.mapping)
def test_integrates(self): # End-to-end scenario for boot_merge: start with an empty boot # resources dict, and receive one resource from Simplestreams. total_resources = BootImageMapping() resources_from_repo = set_resource() download_descriptions.boot_merge(total_resources, resources_from_repo) # Since we started with an empty dict, the result contains the same # item that we got from Simplestreams, and nothing else. self.assertEqual(resources_from_repo.mapping, total_resources.mapping)
def test_obeys_filters(self): filters = [{ "os": factory.make_name("os"), "arches": [factory.make_name("other-arch")], "subarches": [factory.make_name("other-subarch")], "release": factory.make_name("other-release"), "label": [factory.make_name("other-label")], }] total_resources = BootImageMapping() resources_from_repo = set_resource() download_descriptions.boot_merge(total_resources, resources_from_repo, filters=filters) self.assertEqual({}, total_resources.mapping)
def test_obeys_filters(self): filters = [ { 'os': factory.make_name('os'), 'arches': [factory.make_name('other-arch')], 'subarches': [factory.make_name('other-subarch')], 'release': factory.make_name('other-release'), 'label': [factory.make_name('other-label')], }, ] total_resources = BootImageMapping() resources_from_repo = set_resource() download_descriptions.boot_merge(total_resources, resources_from_repo, filters=filters) self.assertEqual({}, total_resources.mapping)