Best Python code snippet using tempest_python
test_trunk.py
Source:test_trunk.py  
...38        self.assertTrue(39            policy.enforce(self.context, 'update_trunk', self.target))40        self.assertTrue(41            policy.enforce(self.context, 'update_trunk', self.alt_target))42    def test_delete_trunk(self):43        self.assertTrue(44            policy.enforce(self.context, 'delete_trunk', self.target))45        self.assertTrue(46            policy.enforce(self.context, 'delete_trunk', self.alt_target))47    def test_get_subports(self):48        self.assertTrue(49            policy.enforce(self.context, 'get_subports', self.target))50        self.assertTrue(51            policy.enforce(self.context, 'get_subports', self.alt_target))52    def test_add_subports(self):53        self.assertTrue(54            policy.enforce(self.context, 'add_subports', self.target))55        self.assertTrue(56            policy.enforce(self.context, 'add_subports', self.alt_target))57    def test_remove_subports(self):58        self.assertTrue(59            policy.enforce(self.context, 'remove_subports', self.target))60        self.assertTrue(61            policy.enforce(self.context, 'remove_subports', self.alt_target))62class SystemMemberTests(SystemAdminTests):63    def setUp(self):64        super(SystemMemberTests, self).setUp()65        self.context = self.system_member_ctx66    def test_create_trunk(self):67        self.assertRaises(68            base_policy.PolicyNotAuthorized,69            policy.enforce,70            self.context, 'create_trunk', self.target)71        self.assertRaises(72            base_policy.PolicyNotAuthorized,73            policy.enforce,74            self.context, 'create_trunk', self.alt_target)75    def test_update_trunk(self):76        self.assertRaises(77            base_policy.PolicyNotAuthorized,78            policy.enforce,79            self.context, 'update_trunk', self.target)80        self.assertRaises(81            base_policy.PolicyNotAuthorized,82            policy.enforce,83            self.context, 'update_trunk', self.alt_target)84    def test_delete_trunk(self):85        self.assertRaises(86            base_policy.PolicyNotAuthorized,87            policy.enforce,88            self.context, 'delete_trunk', self.target)89        self.assertRaises(90            base_policy.PolicyNotAuthorized,91            policy.enforce,92            self.context, 'delete_trunk', self.alt_target)93    def test_add_subports(self):94        self.assertRaises(95            base_policy.PolicyNotAuthorized,96            policy.enforce,97            self.context, 'add_subports', self.target)98        self.assertRaises(99            base_policy.PolicyNotAuthorized,100            policy.enforce,101            self.context, 'add_subports', self.alt_target)102    def test_remove_subports(self):103        self.assertRaises(104            base_policy.PolicyNotAuthorized,105            policy.enforce,106            self.context, 'remove_subports', self.target)107        self.assertRaises(108            base_policy.PolicyNotAuthorized,109            policy.enforce,110            self.context, 'remove_subports', self.alt_target)111class SystemReaderTests(SystemMemberTests):112    def setUp(self):113        super(SystemReaderTests, self).setUp()114        self.context = self.system_reader_ctx115class ProjectAdminTests(TrunkAPITestCase):116    def setUp(self):117        super(ProjectAdminTests, self).setUp()118        self.context = self.project_admin_ctx119    def test_create_trunk(self):120        self.assertTrue(121            policy.enforce(self.context, 'create_trunk', self.target))122        self.assertRaises(123            base_policy.PolicyNotAuthorized,124            policy.enforce,125            self.context, 'create_trunk', self.alt_target)126    def test_get_trunk(self):127        self.assertTrue(128            policy.enforce(self.context, 'get_trunk', self.target))129        self.assertRaises(130            base_policy.PolicyNotAuthorized,131            policy.enforce,132            self.context, 'get_trunk', self.alt_target)133    def test_update_trunk(self):134        self.assertTrue(135            policy.enforce(self.context, 'update_trunk', self.target))136        self.assertRaises(137            base_policy.PolicyNotAuthorized,138            policy.enforce,139            self.context, 'update_trunk', self.alt_target)140    def test_delete_trunk(self):141        self.assertTrue(142            policy.enforce(self.context, 'delete_trunk', self.target))143        self.assertRaises(144            base_policy.PolicyNotAuthorized,145            policy.enforce,146            self.context, 'delete_trunk', self.alt_target)147    def test_get_subports(self):148        self.assertTrue(149            policy.enforce(self.context, 'get_subports', self.target))150        self.assertRaises(151            base_policy.PolicyNotAuthorized,152            policy.enforce,153            self.context, 'get_subports', self.alt_target)154    def test_add_subports(self):155        self.assertTrue(156            policy.enforce(self.context, 'add_subports', self.target))157        self.assertRaises(158            base_policy.PolicyNotAuthorized,159            policy.enforce,160            self.context, 'add_subports', self.alt_target)161    def test_remove_subports(self):162        self.assertTrue(163            policy.enforce(self.context, 'remove_subports', self.target))164        self.assertRaises(165            base_policy.PolicyNotAuthorized,166            policy.enforce,167            self.context, 'remove_subports', self.alt_target)168class ProjectMemberTests(ProjectAdminTests):169    def setUp(self):170        super(ProjectMemberTests, self).setUp()171        self.context = self.project_member_ctx172class ProjectReaderTests(ProjectMemberTests):173    def setUp(self):174        super(ProjectReaderTests, self).setUp()175        self.context = self.project_reader_ctx176    def test_create_trunk(self):177        self.assertRaises(178            base_policy.PolicyNotAuthorized,179            policy.enforce,180            self.context, 'create_trunk', self.target)181        self.assertRaises(182            base_policy.PolicyNotAuthorized,183            policy.enforce,184            self.context, 'create_trunk', self.alt_target)185    def test_update_trunk(self):186        self.assertRaises(187            base_policy.PolicyNotAuthorized,188            policy.enforce,189            self.context, 'update_trunk', self.target)190        self.assertRaises(191            base_policy.PolicyNotAuthorized,192            policy.enforce,193            self.context, 'update_trunk', self.alt_target)194    def test_delete_trunk(self):195        self.assertRaises(196            base_policy.PolicyNotAuthorized,197            policy.enforce,198            self.context, 'delete_trunk', self.target)199        self.assertRaises(200            base_policy.PolicyNotAuthorized,201            policy.enforce,202            self.context, 'delete_trunk', self.alt_target)203    def test_add_subports(self):204        self.assertRaises(205            base_policy.PolicyNotAuthorized,206            policy.enforce,207            self.context, 'add_subports', self.target)208        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!!
