def test__get_boot_sources_v1_sets_os_to_wildcard(self): sources = [{ "path": factory.make_url(), "selections": [ { "release": "trusty", "arches": ["amd64"], "subarches": ["generic"], "labels": ["release"], }, { "release": "precise", "arches": ["amd64"], "subarches": ["generic"], "labels": ["release"], }, ], }] clock = Clock() client_call = Mock() client_call.side_effect = [ defer.fail(UnhandledCommand()), defer.succeed(dict(sources=sources)), ] service = ImageDownloadService(sentinel.rpc, sentinel.tftp_root, clock) sources = yield service._get_boot_sources(client_call) os_selections = [ selection.get("os") for source in sources["sources"] for selection in source["selections"] ] self.assertEqual(["*", "*"], os_selections)
def test_calls_ListBootImages_if_raised_UnhandledCommand(self): rack_controller = factory.make_RackController() mock_client = MagicMock() self.patch_autospec( boot_images_module, "getClientFor" ).return_value = mock_client mock_client.return_value.wait.side_effect = [ UnhandledCommand(), {"images": []}, ] get_boot_images(rack_controller) self.assertThat( mock_client, MockCallsMatch(call(ListBootImagesV2), call(ListBootImages)), )
def test__get_boot_sources_calls_get_boot_sources_v1_on_v2_missing(self): clock = Clock() client_call = Mock() client_call.side_effect = [ defer.fail(UnhandledCommand()), defer.succeed(dict(sources=[])), ] client_call.localIdent = factory.make_UUID() service = ImageDownloadService(sentinel.rpc, sentinel.tftp_root, clock) yield service._get_boot_sources(client_call) self.assertThat( client_call, MockCallsMatch(call(GetBootSourcesV2, uuid=client_call.localIdent), call(GetBootSources, uuid=client_call.localIdent)))
def test__get_boot_sources_v1_sets_os_to_wildcard(self): sources = [ { 'path': factory.make_url(), 'selections': [ { 'release': "trusty", 'arches': ["amd64"], 'subarches': ["generic"], 'labels': ["release"], }, { 'release': "precise", 'arches': ["amd64"], 'subarches': ["generic"], 'labels': ["release"], }, ], }, ] clock = Clock() client_call = Mock() client_call.side_effect = [ defer.fail(UnhandledCommand()), defer.succeed(dict(sources=sources)), ] service = ImageDownloadService( sentinel.rpc, sentinel.tftp_root, clock) sources = yield service._get_boot_sources(client_call) os_selections = [ selection.get('os') for source in sources['sources'] for selection in source['selections'] ] self.assertEqual(['*', '*'], os_selections)