Best Python code snippet using tempest_python
test_aggregates.py
Source:test_aggregates.py
...270 self.req, "1", body={"add_host": 1})271 def test_add_host_with_non_string(self):272 self.assertRaises(exc.HTTPBadRequest, self.controller._add_host,273 self.req, "1", body={"add_host": {"host": 1}})274 def test_remove_host(self):275 def stub_remove_host_from_aggregate(context, aggregate, host):276 self.assertEqual(context, self.context, "context")277 self.assertEqual("1", aggregate, "aggregate")278 self.assertEqual("host1", host, "host")279 stub_remove_host_from_aggregate.called = True280 return {}281 self.stubs.Set(self.controller.api,282 "remove_host_from_aggregate",283 stub_remove_host_from_aggregate)284 self.controller._remove_host(self.req, "1",285 body={"remove_host": {"host": "host1"}})286 self.assertTrue(stub_remove_host_from_aggregate.called)287 self.assertEqual(self.controller._remove_host.wsgi_code, 202)288 def test_remove_host_no_admin(self):289 exc = self.assertRaises(exception.PolicyNotAuthorized,290 self.controller._remove_host,291 self.user_req, "1",292 body={"remove_host": {"host": "host1"}})293 self.assertIn("compute_extension:v3:os-aggregates:remove_host",294 exc.format_message())295 def test_remove_host_with_host_not_in_aggregate(self):296 def stub_remove_host_from_aggregate(context, aggregate, host):297 raise exception.AggregateHostNotFound(aggregate_id=aggregate,298 host=host)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!