def test_success_has_locations(self, avail_mock): avail_mock.return_value = True locations = [mock.sentinel.loc1] image_meta = mock.MagicMock(locations=locations, spec=TestGetLocations.ImageSpecV2) client_mock = mock.MagicMock() client_mock.call.return_value = image_meta locs = glance._get_locations(client_mock, mock.sentinel.ctx, mock.sentinel.image_id) client_mock.call.assert_called_once_with(mock.sentinel.ctx, 2, "get", mock.sentinel.image_id) self.assertEqual(locations, locs) avail_mock.assert_called_once_with(mock.sentinel.ctx, image_meta)
def test_success_direct_uri_added_to_locations(self, avail_mock): avail_mock.return_value = True locations = [mock.sentinel.loc1] image_meta = mock.MagicMock( locations=locations, spec=TestGetLocations.ImageSpecV2, direct_uri=mock.sentinel.duri ) client_mock = mock.MagicMock() client_mock.call.return_value = image_meta locs = glance._get_locations(client_mock, mock.sentinel.ctx, mock.sentinel.image_id) client_mock.call.assert_called_once_with(mock.sentinel.ctx, 2, "get", mock.sentinel.image_id) expected = locations expected.append({"url": mock.sentinel.duri, "metadata": {}}) self.assertEqual(expected, locs)
def test_success_has_locations(self, avail_mock): avail_mock.return_value = True locations = [mock.sentinel.loc1] image_meta = mock.MagicMock(locations=locations, spec=TestGetLocations.ImageSpecV2) client_mock = mock.MagicMock() client_mock.call.return_value = image_meta locs = glance._get_locations(client_mock, mock.sentinel.ctx, mock.sentinel.image_id) client_mock.call.assert_called_once_with(mock.sentinel.ctx, 2, 'get', mock.sentinel.image_id) self.assertEqual(locations, locs) avail_mock.assert_called_once_with(mock.sentinel.ctx, image_meta)
def test_success_direct_uri_added_to_locations(self, avail_mock): avail_mock.return_value = True locations = [mock.sentinel.loc1] image_meta = mock.MagicMock(locations=locations, spec=TestGetLocations.ImageSpecV2, direct_uri=mock.sentinel.duri) client_mock = mock.MagicMock() client_mock.call.return_value = image_meta locs = glance._get_locations(client_mock, mock.sentinel.ctx, mock.sentinel.image_id) client_mock.call.assert_called_once_with(mock.sentinel.ctx, 2, 'get', mock.sentinel.image_id) expected = locations expected.append({"url": mock.sentinel.duri, "metadata": {}}) self.assertEqual(expected, locs)