Best Python code snippet using tempest_python
test_agents_rbac.py
Source:test_agents_rbac.py  
...104            self.agent['id'], router_id=self.router['id'])105    @decorators.idempotent_id('8138cfc9-3e48-4a34-adf6-894077aa1be4')106    @rbac_rule_validation.action(service="neutron",107                                 rule="delete_l3-router")108    def test_delete_router_from_l3_agent(self):109        """Delete router from L3 agent test.110        RBAC test for the neutron delete_l3-router policy111        """112        self.agents_client.create_router_on_l3_agent(113            self.agent['id'], router_id=self.router['id'])114        self.addCleanup(115            test_utils.call_and_ignore_notfound_exc,116            self.agents_client.delete_router_from_l3_agent,117            self.agent['id'], router_id=self.router['id'])118        self.rbac_utils.switch_role(self, toggle_rbac_role=True)119        self.agents_client.delete_router_from_l3_agent(120            self.agent['id'], router_id=self.router['id'])121class DHCPAgentSchedulersRbacTest(base.BaseNetworkRbacTest):122    @classmethod123    def skip_checks(cls):124        super(DHCPAgentSchedulersRbacTest, cls).skip_checks()125        if not test.is_extension_enabled('dhcp_agent_scheduler', 'network'):126            msg = "dhcp_agent_scheduler extension not enabled."127            raise cls.skipException(msg)128    @classmethod129    def resource_setup(cls):130        super(DHCPAgentSchedulersRbacTest, cls).resource_setup()131        cls.agent = None132    def setUp(self):133        super(DHCPAgentSchedulersRbacTest, self).setUp()...agents_client.py
Source:agents_client.py  
...36        # link to api-site.37        # LP: https://bugs.launchpad.net/openstack-api-site/+bug/152667038        uri = '/agents/%s/l3-routers' % agent_id39        return self.create_resource(uri, kwargs)40    def delete_router_from_l3_agent(self, agent_id, router_id):41        uri = '/agents/%s/l3-routers/%s' % (agent_id, router_id)42        return self.delete_resource(uri)43    def list_networks_hosted_by_one_dhcp_agent(self, agent_id):44        uri = '/agents/%s/dhcp-networks' % agent_id45        return self.list_resources(uri)46    def delete_network_from_dhcp_agent(self, agent_id, network_id):47        uri = '/agents/%s/dhcp-networks/%s' % (agent_id,48                                               network_id)49        return self.delete_resource(uri)50    def add_dhcp_agent_to_network(self, agent_id, **kwargs):51        # TODO(piyush): Current api-site doesn't contain this API description.52        # After fixing the api-site, we need to fix here also for putting the53        # link to api-site.54        # LP: https://bugs.launchpad.net/openstack-api-site/+bug/1526212...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!!
