How to use _create_test_aggregate method in tempest

Best Python code snippet using tempest_python

test_aggregates_negative.py

Source:test_aggregates_negative.py Github

copy

Full Screen

...32 hosts_all = cls.os_adm.hosts_client.list_hosts()['hosts']33 hosts = ([host['host_name']34 for host in hosts_all if host['service'] == 'compute'])35 cls.host = hosts[0]36 def _create_test_aggregate(self):37 aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)38 aggregate = (self.client.create_aggregate(name=aggregate_name)39 ['aggregate'])40 self.addCleanup(self.client.delete_aggregate, aggregate['id'])41 return aggregate42 @test.attr(type=['negative'])43 @decorators.idempotent_id('86a1cb14-da37-4a70-b056-903fd56dfe29')44 def test_aggregate_create_as_user(self):45 # Regular user is not allowed to create an aggregate.46 aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)47 self.assertRaises(lib_exc.Forbidden,48 self.user_client.create_aggregate,49 name=aggregate_name)50 @test.attr(type=['negative'])51 @decorators.idempotent_id('3b8a1929-3793-4e92-bcb4-dfa572ee6c1d')52 def test_aggregate_create_aggregate_name_length_less_than_1(self):53 # the length of aggregate name should >= 1 and <=25554 self.assertRaises(lib_exc.BadRequest,55 self.client.create_aggregate,56 name='')57 @test.attr(type=['negative'])58 @decorators.idempotent_id('4c194563-543b-4e70-a719-557bbe947fac')59 def test_aggregate_create_aggregate_name_length_exceeds_255(self):60 # the length of aggregate name should >= 1 and <=25561 aggregate_name = 'a' * 25662 self.assertRaises(lib_exc.BadRequest,63 self.client.create_aggregate,64 name=aggregate_name)65 @test.attr(type=['negative'])66 @decorators.idempotent_id('9c23a291-b0b1-487b-b464-132e061151b3')67 def test_aggregate_create_with_existent_aggregate_name(self):68 # creating an aggregate with existent aggregate name is forbidden69 aggregate = self._create_test_aggregate()70 self.assertRaises(lib_exc.Conflict,71 self.client.create_aggregate,72 name=aggregate['name'])73 @test.attr(type=['negative'])74 @decorators.idempotent_id('cd6de795-c15d-45f1-8d9e-813c6bb72a3d')75 def test_aggregate_delete_as_user(self):76 # Regular user is not allowed to delete an aggregate.77 aggregate = self._create_test_aggregate()78 self.assertRaises(lib_exc.Forbidden,79 self.user_client.delete_aggregate,80 aggregate['id'])81 @test.attr(type=['negative'])82 @decorators.idempotent_id('b7d475a6-5dcd-4ff4-b70a-cd9de66a6672')83 def test_aggregate_list_as_user(self):84 # Regular user is not allowed to list aggregates.85 self.assertRaises(lib_exc.Forbidden,86 self.user_client.list_aggregates)87 @test.attr(type=['negative'])88 @decorators.idempotent_id('557cad12-34c9-4ff4-95f0-22f0dfbaf7dc')89 def test_aggregate_get_details_as_user(self):90 # Regular user is not allowed to get aggregate details.91 aggregate = self._create_test_aggregate()92 self.assertRaises(lib_exc.Forbidden,93 self.user_client.show_aggregate,94 aggregate['id'])95 @test.attr(type=['negative'])96 @decorators.idempotent_id('c74f4bf1-4708-4ff2-95a0-f49eaca951bd')97 def test_aggregate_delete_with_invalid_id(self):98 # Delete an aggregate with invalid id should raise exceptions.99 self.assertRaises(lib_exc.NotFound,100 self.client.delete_aggregate, -1)101 @test.attr(type=['negative'])102 @decorators.idempotent_id('3c916244-2c46-49a4-9b55-b20bb0ae512c')103 def test_aggregate_get_details_with_invalid_id(self):104 # Get aggregate details with invalid id should raise exceptions.105 self.assertRaises(lib_exc.NotFound,106 self.client.show_aggregate, -1)107 @test.attr(type=['negative'])108 @decorators.idempotent_id('0ef07828-12b4-45ba-87cc-41425faf5711')109 def test_aggregate_add_non_exist_host(self):110 # Adding a non-exist host to an aggregate should raise exceptions.111 hosts_all = self.os_adm.hosts_client.list_hosts()['hosts']112 hosts = map(lambda x: x['host_name'], hosts_all)113 while True:114 non_exist_host = data_utils.rand_name('nonexist_host')115 if non_exist_host not in hosts:116 break117 aggregate = self._create_test_aggregate()118 self.assertRaises(lib_exc.NotFound, self.client.add_host,119 aggregate['id'], host=non_exist_host)120 @test.attr(type=['negative'])121 @decorators.idempotent_id('7324c334-bd13-4c93-8521-5877322c3d51')122 def test_aggregate_add_host_as_user(self):123 # Regular user is not allowed to add a host to an aggregate.124 aggregate = self._create_test_aggregate()125 self.assertRaises(lib_exc.Forbidden,126 self.user_client.add_host,127 aggregate['id'], host=self.host)128 @test.attr(type=['negative'])129 @decorators.idempotent_id('19dd44e1-c435-4ee1-a402-88c4f90b5950')130 def test_aggregate_add_existent_host(self):131 self.useFixture(fixtures.LockFixture('availability_zone'))132 aggregate = self._create_test_aggregate()133 self.client.add_host(aggregate['id'], host=self.host)134 self.addCleanup(self.client.remove_host, aggregate['id'],135 host=self.host)136 self.assertRaises(lib_exc.Conflict, self.client.add_host,137 aggregate['id'], host=self.host)138 @test.attr(type=['negative'])139 @decorators.idempotent_id('7a53af20-137a-4e44-a4ae-e19260e626d9')140 def test_aggregate_remove_host_as_user(self):141 # Regular user is not allowed to remove a host from an aggregate.142 self.useFixture(fixtures.LockFixture('availability_zone'))143 aggregate = self._create_test_aggregate()144 self.client.add_host(aggregate['id'], host=self.host)145 self.addCleanup(self.client.remove_host, aggregate['id'],146 host=self.host)147 self.assertRaises(lib_exc.Forbidden,148 self.user_client.remove_host,149 aggregate['id'], host=self.host)150 @test.attr(type=['negative'])151 @decorators.idempotent_id('95d6a6fa-8da9-4426-84d0-eec0329f2e4d')152 def test_aggregate_remove_nonexistent_host(self):153 aggregate = self._create_test_aggregate()154 self.assertRaises(lib_exc.NotFound, self.client.remove_host,...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful