Container Infrastructure Management Service for OpenStack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_baymodel_admin.py 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  2. # not use this file except in compliance with the License. You may obtain
  3. # a copy of the License at
  4. #
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. #
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  9. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  10. # License for the specific language governing permissions and limitations
  11. # under the License.
  12. import testtools
  13. from magnum.tests.functional.api import base
  14. from magnum.tests.functional.common import datagen
  15. class BayModelAdminTest(base.BaseTempestTest):
  16. """Tests for baymodel admin operations."""
  17. def __init__(self, *args, **kwargs):
  18. super(BayModelAdminTest, self).__init__(*args, **kwargs)
  19. self.baymodels = []
  20. self.baymodel_client = None
  21. self.keypairs_client = None
  22. def setUp(self):
  23. try:
  24. super(BayModelAdminTest, self).setUp()
  25. (self.baymodel_client,
  26. self.keypairs_client) = self.get_clients_with_new_creds(
  27. type_of_creds='admin',
  28. request_type='baymodel')
  29. except Exception:
  30. self.tearDown()
  31. raise
  32. def tearDown(self):
  33. for baymodel_id in self.baymodels:
  34. self._delete_baymodel(baymodel_id)
  35. self.baymodels.remove(baymodel_id)
  36. super(BayModelAdminTest, self).tearDown()
  37. def _create_baymodel(self, baymodel_model):
  38. resp, model = self.baymodel_client.post_baymodel(baymodel_model)
  39. self.assertEqual(201, resp.status)
  40. self.baymodels.append(model.uuid)
  41. return resp, model
  42. def _delete_baymodel(self, baymodel_id):
  43. resp, model = self.baymodel_client.delete_baymodel(baymodel_id)
  44. self.assertEqual(204, resp.status)
  45. return resp, model
  46. @testtools.testcase.attr('positive')
  47. def test_create_get_public_baymodel(self):
  48. gen_model = datagen.valid_swarm_baymodel(is_public=True)
  49. resp, model = self._create_baymodel(gen_model)
  50. resp, model = self.baymodel_client.get_baymodel(model.uuid)
  51. self.assertEqual(200, resp.status)
  52. self.assertTrue(model.public)
  53. @testtools.testcase.attr('positive')
  54. def test_update_baymodel_public_by_uuid(self):
  55. path = "/public"
  56. gen_model = datagen.baymodel_data_with_valid_keypair_image_flavor()
  57. resp, old_model = self._create_baymodel(gen_model)
  58. patch_model = datagen.baymodel_replace_patch_data(path, value=True)
  59. resp, new_model = self.baymodel_client.patch_baymodel(
  60. old_model.uuid, patch_model)
  61. self.assertEqual(200, resp.status)
  62. resp, model = self.baymodel_client.get_baymodel(new_model.uuid)
  63. self.assertEqual(200, resp.status)
  64. self.assertTrue(model.public)