Best Python code snippet using tempest_python
test_floatingip.py
Source:test_floatingip.py  
...41            policy.enforce(self.context, "get_floatingip", self.target))42    def test_update_floatingip(self):43        self.assertTrue(44            policy.enforce(self.context, "update_floatingip", self.target))45    def test_delete_floatingip(self):46        self.assertTrue(47            policy.enforce(self.context, "delete_floatingip", self.target))48class SystemMemberTests(FloatingIPAPITestCase):49    def setUp(self):50        super(SystemMemberTests, self).setUp()51        self.context = self.system_member_ctx52    def test_create_floatingip(self):53        self.assertRaises(54            base_policy.PolicyNotAuthorized,55            policy.enforce, self.context, "create_floatingip", self.target)56    def test_create_floatingip_with_ip_address(self):57        self.assertRaises(58            base_policy.PolicyNotAuthorized,59            policy.enforce,60            self.context, "create_floatingip:floating_ip_address", self.target)61    def test_get_floatingip(self):62        self.assertTrue(63            policy.enforce(self.context, "get_floatingip", self.target))64    def test_update_floatingip(self):65        self.assertRaises(66            base_policy.PolicyNotAuthorized,67            policy.enforce, self.context, "update_floatingip", self.target)68    def test_delete_floatingip(self):69        self.assertRaises(70            base_policy.PolicyNotAuthorized,71            policy.enforce, self.context, "delete_floatingip", self.target)72class SystemReaderTests(SystemMemberTests):73    def setUp(self):74        super(SystemReaderTests, self).setUp()75        self.context = self.system_reader_ctx76class ProjectAdminTests(FloatingIPAPITestCase):77    def setUp(self):78        super(ProjectAdminTests, self).setUp()79        self.context = self.project_admin_ctx80    def test_create_floatingip(self):81        self.assertTrue(82            policy.enforce(self.context, "create_floatingip", self.target))83    def test_create_floatingip_other_project(self):84        self.assertRaises(85            base_policy.PolicyNotAuthorized,86            policy.enforce, self.context, "create_floatingip", self.alt_target)87    def test_create_floatingip_with_ip_address(self):88        self.assertRaises(89            base_policy.PolicyNotAuthorized,90            policy.enforce,91            self.context, "create_floatingip:floating_ip_address", self.target)92    def test_create_floatingip_with_ip_address_other_project(self):93        self.assertRaises(94            base_policy.PolicyNotAuthorized,95            policy.enforce,96            self.context, "create_floatingip:floating_ip_address",97            self.alt_target)98    def test_get_floatingip(self):99        self.assertTrue(100            policy.enforce(self.context, "get_floatingip", self.target))101    def test_get_floatingip_other_project(self):102        self.assertRaises(103            base_policy.PolicyNotAuthorized,104            policy.enforce, self.context, "get_floatingip", self.alt_target)105    def test_update_floatingip(self):106        self.assertTrue(107            policy.enforce(self.context, "update_floatingip", self.target))108    def test_update_floatingip_other_project(self):109        self.assertRaises(110            base_policy.PolicyNotAuthorized,111            policy.enforce, self.context, "update_floatingip", self.alt_target)112    def test_delete_floatingip(self):113        self.assertTrue(114            policy.enforce(self.context, "delete_floatingip", self.target))115    def test_delete_floatingip_other_project(self):116        self.assertRaises(117            base_policy.PolicyNotAuthorized,118            policy.enforce, self.context, "delete_floatingip", self.alt_target)119class ProjectMemberTests(ProjectAdminTests):120    def setUp(self):121        super(ProjectMemberTests, self).setUp()122        self.context = self.project_member_ctx123class ProjectReaderTests(FloatingIPAPITestCase):124    def setUp(self):125        super(ProjectReaderTests, self).setUp()126        self.context = self.project_reader_ctx127    def test_create_floatingip(self):128        self.assertRaises(129            base_policy.PolicyNotAuthorized,130            policy.enforce, self.context, "create_floatingip", self.target)131    def test_create_floatingip_other_project(self):132        self.assertRaises(133            base_policy.PolicyNotAuthorized,134            policy.enforce, self.context, "create_floatingip", self.alt_target)135    def test_create_floatingip_with_ip_address(self):136        self.assertRaises(137            base_policy.PolicyNotAuthorized,138            policy.enforce,139            self.context, "create_floatingip:floating_ip_address", self.target)140    def test_create_floatingip_with_ip_address_other_project(self):141        self.assertRaises(142            base_policy.PolicyNotAuthorized,143            policy.enforce,144            self.context, "create_floatingip:floating_ip_address",145            self.alt_target)146    def test_get_floatingip(self):147        self.assertTrue(148            policy.enforce(self.context, "get_floatingip", self.target))149    def test_get_floatingip_other_project(self):150        self.assertRaises(151            base_policy.PolicyNotAuthorized,152            policy.enforce, self.context, "get_floatingip", self.alt_target)153    def test_update_floatingip(self):154        self.assertRaises(155            base_policy.PolicyNotAuthorized,156            policy.enforce, self.context, "update_floatingip", self.target)157    def test_update_floatingip_other_project(self):158        self.assertRaises(159            base_policy.PolicyNotAuthorized,160            policy.enforce, self.context, "update_floatingip", self.alt_target)161    def test_delete_floatingip(self):162        self.assertRaises(163            base_policy.PolicyNotAuthorized,164            policy.enforce, self.context, "delete_floatingip", self.target)165    def test_delete_floatingip_other_project(self):166        self.assertRaises(167            base_policy.PolicyNotAuthorized,...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!!
