Best Python code snippet using tempest_python
test_subnetpool.py
Source:test_subnetpool.py
...59 'update_subnetpool:is_default', self.target))60 self.assertTrue(61 policy.enforce(self.context,62 'update_subnetpool:is_default', self.alt_target))63 def test_delete_subnetpool(self):64 self.assertTrue(65 policy.enforce(self.context, 'delete_subnetpool', self.target))66 self.assertTrue(67 policy.enforce(self.context, 'delete_subnetpool', self.alt_target))68 def test_onboard_network_subnets(self):69 self.assertTrue(70 policy.enforce(self.context,71 'onboard_network_subnets', self.target))72 self.assertTrue(73 policy.enforce(self.context,74 'onboard_network_subnets', self.alt_target))75 def test_add_prefixes(self):76 self.assertTrue(77 policy.enforce(self.context, 'add_prefixes', self.target))78 self.assertTrue(79 policy.enforce(self.context, 'add_prefixes', self.alt_target))80 def test_remove_prefixes(self):81 self.assertTrue(82 policy.enforce(self.context, 'remove_prefixes', self.target))83 self.assertTrue(84 policy.enforce(self.context, 'remove_prefixes', self.alt_target))85class SystemMemberTests(SystemAdminTests):86 def setUp(self):87 super(SystemMemberTests, self).setUp()88 self.context = self.system_member_ctx89 def test_create_subnetpool(self):90 self.assertRaises(91 base_policy.PolicyNotAuthorized,92 policy.enforce,93 self.context, 'create_subnetpool', self.target)94 self.assertRaises(95 base_policy.PolicyNotAuthorized,96 policy.enforce,97 self.context, 'create_subnetpool', self.alt_target)98 def test_create_subnetpool_shared(self):99 self.assertRaises(100 base_policy.PolicyNotAuthorized,101 policy.enforce,102 self.context, 'create_subnetpool:shared', self.target)103 self.assertRaises(104 base_policy.PolicyNotAuthorized,105 policy.enforce,106 self.context, 'create_subnetpool:shared', self.alt_target)107 def test_create_subnetpool_default(self):108 self.assertRaises(109 base_policy.PolicyNotAuthorized,110 policy.enforce,111 self.context, 'create_subnetpool:is_default', self.target)112 self.assertRaises(113 base_policy.PolicyNotAuthorized,114 policy.enforce,115 self.context, 'create_subnetpool:is_default', self.alt_target)116 def test_update_subnetpool(self):117 self.assertRaises(118 base_policy.PolicyNotAuthorized,119 policy.enforce,120 self.context, 'update_subnetpool', self.target)121 self.assertRaises(122 base_policy.PolicyNotAuthorized,123 policy.enforce,124 self.context, 'update_subnetpool', self.alt_target)125 def test_update_subnetpool_default(self):126 self.assertRaises(127 base_policy.PolicyNotAuthorized,128 policy.enforce,129 self.context, 'update_subnetpool:is_default', self.target)130 self.assertRaises(131 base_policy.PolicyNotAuthorized,132 policy.enforce,133 self.context, 'update_subnetpool:is_default', self.alt_target)134 def test_delete_subnetpool(self):135 self.assertRaises(136 base_policy.PolicyNotAuthorized,137 policy.enforce,138 self.context, 'delete_subnetpool', self.target)139 self.assertRaises(140 base_policy.PolicyNotAuthorized,141 policy.enforce,142 self.context, 'delete_subnetpool', self.alt_target)143 def test_onboard_network_subnets(self):144 self.assertRaises(145 base_policy.PolicyNotAuthorized,146 policy.enforce,147 self.context, 'onboard_network_subnets', self.target)148 self.assertRaises(149 base_policy.PolicyNotAuthorized,150 policy.enforce,151 self.context, 'onboard_network_subnets', self.alt_target)152 def test_add_prefixes(self):153 self.assertRaises(154 base_policy.PolicyNotAuthorized,155 policy.enforce,156 self.context, 'add_prefixes', self.target)157 self.assertRaises(158 base_policy.PolicyNotAuthorized,159 policy.enforce,160 self.context, 'add_prefixes', self.alt_target)161 def test_remove_prefixes(self):162 self.assertRaises(163 base_policy.PolicyNotAuthorized,164 policy.enforce,165 self.context, 'remove_prefixes', self.target)166 self.assertRaises(167 base_policy.PolicyNotAuthorized,168 policy.enforce,169 self.context, 'remove_prefixes', self.alt_target)170class SystemReaderTests(SystemMemberTests):171 def setUp(self):172 super(SystemReaderTests, self).setUp()173 self.context = self.system_reader_ctx174class ProjectAdminTests(SubnetpoolAPITestCase):175 def setUp(self):176 super(ProjectAdminTests, self).setUp()177 self.context = self.project_admin_ctx178 def test_create_subnetpool(self):179 self.assertTrue(180 policy.enforce(self.context, 'create_subnetpool', self.target))181 self.assertRaises(182 base_policy.PolicyNotAuthorized,183 policy.enforce,184 self.context, 'create_subnetpool', self.alt_target)185 def test_create_subnetpool_shared(self):186 self.assertRaises(187 base_policy.PolicyNotAuthorized,188 policy.enforce,189 self.context, 'create_subnetpool:shared', self.target)190 self.assertRaises(191 base_policy.PolicyNotAuthorized,192 policy.enforce,193 self.context, 'create_subnetpool:shared', self.alt_target)194 def test_create_subnetpool_default(self):195 self.assertRaises(196 base_policy.PolicyNotAuthorized,197 policy.enforce,198 self.context, 'create_subnetpool:is_default', self.target)199 self.assertRaises(200 base_policy.PolicyNotAuthorized,201 policy.enforce,202 self.context, 'create_subnetpool:is_default', self.alt_target)203 def test_get_subnetpool(self):204 self.assertTrue(205 policy.enforce(self.context, 'get_subnetpool', self.target))206 self.assertRaises(207 base_policy.PolicyNotAuthorized,208 policy.enforce,209 self.context, 'get_subnetpool', self.alt_target)210 def test_update_subnetpool(self):211 self.assertTrue(212 policy.enforce(self.context, 'update_subnetpool', self.target))213 self.assertRaises(214 base_policy.PolicyNotAuthorized,215 policy.enforce,216 self.context, 'update_subnetpool', self.alt_target)217 def test_update_subnetpool_default(self):218 self.assertRaises(219 base_policy.PolicyNotAuthorized,220 policy.enforce,221 self.context, 'update_subnetpool:is_default', self.target)222 self.assertRaises(223 base_policy.PolicyNotAuthorized,224 policy.enforce,225 self.context, 'update_subnetpool:is_default', self.alt_target)226 def test_delete_subnetpool(self):227 self.assertTrue(228 policy.enforce(self.context, 'delete_subnetpool', self.target))229 self.assertRaises(230 base_policy.PolicyNotAuthorized,231 policy.enforce,232 self.context, 'delete_subnetpool', self.alt_target)233 def test_onboard_network_subnets(self):234 self.assertTrue(235 policy.enforce(self.context,236 'onboard_network_subnets', self.target))237 self.assertRaises(238 base_policy.PolicyNotAuthorized,239 policy.enforce,240 self.context, 'onboard_network_subnets', self.alt_target)241 def test_add_prefixes(self):242 self.assertTrue(243 policy.enforce(self.context, 'add_prefixes', self.target))244 self.assertRaises(245 base_policy.PolicyNotAuthorized,246 policy.enforce,247 self.context, 'add_prefixes', self.alt_target)248 def test_remove_prefixes(self):249 self.assertTrue(250 policy.enforce(self.context, 'remove_prefixes', self.target))251 self.assertRaises(252 base_policy.PolicyNotAuthorized,253 policy.enforce,254 self.context, 'remove_prefixes', self.alt_target)255class ProjectMemberTests(ProjectAdminTests):256 def setUp(self):257 super(ProjectMemberTests, self).setUp()258 self.context = self.project_member_ctx259class ProjectReaderTests(ProjectMemberTests):260 def setUp(self):261 super(ProjectReaderTests, self).setUp()262 self.context = self.project_reader_ctx263 def test_create_subnetpool(self):264 self.assertRaises(265 base_policy.PolicyNotAuthorized,266 policy.enforce,267 self.context, 'create_subnetpool', self.target)268 self.assertRaises(269 base_policy.PolicyNotAuthorized,270 policy.enforce,271 self.context, 'create_subnetpool', self.alt_target)272 def test_update_subnetpool(self):273 self.assertRaises(274 base_policy.PolicyNotAuthorized,275 policy.enforce,276 self.context, 'update_subnetpool', self.target)277 self.assertRaises(278 base_policy.PolicyNotAuthorized,279 policy.enforce,280 self.context, 'update_subnetpool', self.alt_target)281 def test_delete_subnetpool(self):282 self.assertRaises(283 base_policy.PolicyNotAuthorized,284 policy.enforce,285 self.context, 'delete_subnetpool', self.target)286 self.assertRaises(287 base_policy.PolicyNotAuthorized,288 policy.enforce,289 self.context, 'delete_subnetpool', self.alt_target)290 def test_onboard_network_subnets(self):291 self.assertRaises(292 base_policy.PolicyNotAuthorized,293 policy.enforce,294 self.context, 'onboard_network_subnets', self.target)295 self.assertRaises(...
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!!