|
13 | 13 | # License for the specific language governing permissions and limitations |
14 | 14 | # under the License. |
15 | 15 |
|
| 16 | +from novaclient import api_versions |
| 17 | +from novaclient import exceptions |
16 | 18 | from novaclient.tests.unit.fixture_data import aggregates as data |
17 | 19 | from novaclient.tests.unit.fixture_data import client |
18 | 20 | from novaclient.tests.unit import utils |
19 | 21 | from novaclient.tests.unit.v2 import fakes |
20 | 22 | from novaclient.v2 import aggregates |
| 23 | +from novaclient.v2 import images |
21 | 24 |
|
22 | 25 |
|
23 | 26 | class AggregatesTest(utils.FixturedTestCase): |
@@ -161,3 +164,40 @@ def test_delete_aggregate(self): |
161 | 164 | result3 = self.cs.aggregates.delete(aggregate) |
162 | 165 | self.assert_request_id(result3, fakes.FAKE_REQUEST_ID_LIST) |
163 | 166 | self.assert_called('DELETE', '/os-aggregates/1') |
| 167 | + |
| 168 | + |
| 169 | +class AggregatesV281Test(utils.FixturedTestCase): |
| 170 | + api_version = "2.81" |
| 171 | + data_fixture_class = data.Fixture |
| 172 | + |
| 173 | + scenarios = [('original', {'client_fixture_class': client.V1}), |
| 174 | + ('session', {'client_fixture_class': client.SessionV1})] |
| 175 | + |
| 176 | + def setUp(self): |
| 177 | + super(AggregatesV281Test, self).setUp() |
| 178 | + self.cs.api_version = api_versions.APIVersion(self.api_version) |
| 179 | + |
| 180 | + def test_cache_images(self): |
| 181 | + aggregate = self.cs.aggregates.list()[0] |
| 182 | + _images = [images.Image(self.cs.aggregates, {'id': '1'}), |
| 183 | + images.Image(self.cs.aggregates, {'id': '2'})] |
| 184 | + aggregate.cache_images(_images) |
| 185 | + expected_body = {'cache': [{'id': image.id} |
| 186 | + for image in _images]} |
| 187 | + self.assert_called('POST', '/os-aggregates/1/images', |
| 188 | + expected_body) |
| 189 | + |
| 190 | + def test_cache_images_just_ids(self): |
| 191 | + aggregate = self.cs.aggregates.list()[0] |
| 192 | + _images = ['1'] |
| 193 | + aggregate.cache_images(_images) |
| 194 | + expected_body = {'cache': [{'id': '1'}]} |
| 195 | + self.assert_called('POST', '/os-aggregates/1/images', |
| 196 | + expected_body) |
| 197 | + |
| 198 | + def test_cache_images_pre281(self): |
| 199 | + self.cs.api_version = api_versions.APIVersion('2.80') |
| 200 | + aggregate = self.cs.aggregates.list()[0] |
| 201 | + _images = [images.Image(self.cs.aggregates, {'id': '1'})] |
| 202 | + self.assertRaises(exceptions.VersionNotFoundForAPIMethod, |
| 203 | + aggregate.cache_images, _images) |
0 commit comments