def test_rename_existing_name_rejected(self): project_name = utils.random_name(NAME_BASE) self._create_project(project_name) project_id = self._create_project(utils.random_name(NAME_BASE)) resp = self.session.put(f'/projects/{project_id}', json={'Name': project_name}) asserts.assert_equal(resp.status_code, 409)
def test_create_update_get(self): new_project_name = utils.random_name(NAME_BASE) project_id = self._create_project(utils.random_name(NAME_BASE)) resp = self.session.put(f'/projects/{project_id}', json={'Name': new_project_name}) asserts.assert_equal(resp.status_code, 204) project = self._get_project(project_id) asserts.assert_equal(project['Name'], new_project_name)
def test_create_update_get(self): new_flavor_name = utils.random_name(NAME_BASE) flavor_id = self._create_flavor(utils.random_name(NAME_BASE), 1, 64) resp = self.session.put(f'/flavors/{flavor_id}', json={ 'Name': new_flavor_name, 'NumCPUs': 96, 'RAM': 512, }) self.assertEqual(resp.status_code, 204) flavor = self._get_flavor(flavor_id) self.assertEqual(flavor['Name'], new_flavor_name) self.assertEqual(flavor['NumCPUs'], 96) self.assertEqual(flavor['RAM'], 512)
def test_create_get(self): flavor_name = utils.random_name(NAME_BASE) flavor_id = self._create_flavor(flavor_name, 2, 1024) flavor = self._get_flavor(flavor_id) self.assertEqual(flavor['Name'], flavor_name) self.assertEqual(flavor['NumCPUs'], 2) self.assertEqual(flavor['RAM'], 1024)
def test_create_get(self): image_name = utils.random_name(NAME_BASE) image_id = self.create_entity('/images', { 'Name': image_name, 'ProjectId': self.project_id, }) image = self.get_entity(f'/images/{image_id}', image_id) self.assertIn('Name', image) self.assertEqual(image['Name'], image_name) self.assertIn('ProjectId', image) self.assertEqual(image['ProjectId'], self.project_id) project = self._get_project(self.project_id) self.assertIn(image_id, project['ImageIds'])
def setUpClass(cls): project_name = utils.random_name('test-image-project-') cls.project_id = cls()._create_project(project_name)
# License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from tests import base from tests import settings from tests import utils from tests.utils import mixins NAME_BASE = utils.random_name('test-image-') class ImageTest(base.TestCase, mixins.ProjectMixin): project_id = None @classmethod def setUpClass(cls): project_name = utils.random_name('test-image-project-') cls.project_id = cls()._create_project(project_name) @classmethod def tearDownClass(cls): cls.cleanup_project(project_id=cls.project_id) resp = cls.session.delete(f'/projects/{cls.project_id}') assert resp.status_code == 204
# License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from tests import base from tests import settings from tests import utils from tests.utils import mixins NAME_BASE = utils.random_name('test.flavor.') class FlavorTest(base.TestCase, mixins.FlavorMixin): @classmethod def tearDownClass(cls): resp = cls.session.get('/flavors') assert resp.status_code == 200 for flavor in resp.json(): if not flavor['Name'].startswith(NAME_BASE): continue cls.cleanup_flavor(flavor=flavor, timeout=settings.COMMON_TIMEOUT) cls().delete_entity(f'/flavors/{flavor["Id"]}') def test_list(self):
def test_rename_to_invalid_name_rejected(self): project_id = self._create_project(utils.random_name(NAME_BASE)) resp = self.session.put(f'/projects/{project_id}', json={'Name': '<html>'}) asserts.assert_equal(resp.status_code, 400)
def test_same_name_rejected(self): project_name = utils.random_name(NAME_BASE) self._create_project(project_name) resp = self.session.post('/projects', json={'Name': project_name}) asserts.assert_equal(resp.status_code, 409)
def test_create_get(self): project_name = utils.random_name(NAME_BASE) project_id = self._create_project(project_name) project = self._get_project(project_id) asserts.assert_equal(project['Name'], project_name)
# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import asserts from tests import base from tests import settings from tests import utils from tests.utils import mixins NAME_BASE = utils.random_name('test-project-') class ProjectTest(base.TestCase, mixins.ProjectMixin): @classmethod def tearDownClass(cls): resp = cls.session.get('/projects') asserts.assert_equal(resp.status_code, 200) for project in resp.json(): if not project['Name'].startswith(NAME_BASE): continue cls.cleanup_project(project=project, timeout=settings.COMMON_TIMEOUT) resp = cls.session.delete(f'/projects/{project["Id"]}') asserts.assert_equal(resp.status_code, 204)