How to use test_l3 method in avocado

Best Python code snippet using avocado_python

test_extension_portforwardings.py

Source:test_extension_portforwardings.py Github

copy

Full Screen

1# Copyright 2014 OpenStack Foundation2#3# Licensed under the Apache License, Version 2.0 (the "License"); you may4# not use this file except in compliance with the License. You may obtain5# a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the12# License for the specific language governing permissions and limitations13# under the License.14#15import copy16from oslo.config import cfg17from webob import exc18from neutron.common.test_lib import test_config19from neutron.db import portforwardings_db20from neutron.extensions import l321from neutron.extensions import portforwardings22from neutron.openstack.common import log as logging23from neutron.openstack.common import uuidutils24from neutron.tests import fake_notifier25from neutron.tests.unit import test_api_v226from neutron.tests.unit import test_l3_plugin as test_l327LOG = logging.getLogger(__name__)28_uuid = uuidutils.generate_uuid29_get_path = test_api_v2._get_path30class PortForwardingsTestExtensionManager(object):31 def get_resources(self):32 l3.RESOURCE_ATTRIBUTE_MAP['routers'].update(33 portforwardings.EXTENDED_ATTRIBUTES_2_0['routers'])34 return l3.L3.get_resources()35 def get_actions(self):36 return []37 def get_request_extensions(self):38 return []39class TestPortForwardingsIntPlugin(40 test_l3.TestL3NatIntPlugin,41 portforwardings_db.Port_Forwarding_Db_Mixin):42 supported_extension_aliases = ["external-net", "router", "portforwarding"]43class TestPortForwardingsL3NatServicePlugin(44 test_l3.TestL3NatServicePlugin,45 portforwardings_db.Port_Forwarding_Db_Mixin):46 supported_extension_aliases = ["router", "portforwarding"]47class PortForwardingsDBTestCaseBase(object):48 forwardings = [{'outside_port': 2222,49 'inside_addr': '10.0.0.3',50 'inside_port': 22,51 'protocol': 'tcp'52 },53 {'outside_port': 2121,54 'inside_addr': '10.0.0.3',55 'inside_port': 21,56 'protocol': 'tcp'}]57 def _pfwd_update_prepare(self, router_id, subnet_id,58 port_id, pfwds, skip_add=False):59 if not skip_add:60 self._router_interface_action('add', router_id, subnet_id, port_id)61 self._update('routers', router_id,62 {'router': {'portforwardings': pfwds}})63 return self._show('routers', router_id)64 def _pfwd_update_cleanup(self, port_id, subnet_id, router_id, pfwds):65 self._update('routers', router_id,66 {'router': {'portforwardings': pfwds}})67 self._router_interface_action('remove', router_id, subnet_id, port_id)68 def test_pfwd_update_with_one_rule(self):69 with self.router() as r:70 with self.subnet(cidr='10.0.0.0/24') as s:71 with self.port(subnet=s, no_delete=True) as p:72 body = self._pfwd_update_prepare(r['router']['id'],73 None, p['port']['id'],74 self.forwardings[0:1])75 self.assertEqual(body['router']['portforwardings'],76 self.forwardings[0:1])77 self._pfwd_update_cleanup(p['port']['id'],78 None, r['router']['id'], [])79 def test_pfwd_update_with_multiple_rules(self):80 with self.router() as r:81 with self.subnet(cidr='10.0.0.0/24') as s:82 with self.port(subnet=s, no_delete=True) as p:83 body = self._pfwd_update_prepare(r['router']['id'],84 None, p['port']['id'],85 self.forwardings)86 self.assertEqual(sorted(body['router']['portforwardings']),87 sorted(self.forwardings))88 self._pfwd_update_cleanup(p['port']['id'],89 None, r['router']['id'], [])90 def test_pfwd_update_with_duplicate_rules(self):91 duplicated = [self.forwardings[0], self.forwardings[0]]92 with self.router() as r:93 with self.subnet(cidr='10.0.0.0/24') as s:94 with self.port(subnet=s, no_delete=True) as p:95 self._router_interface_action('add',96 r['router']['id'],97 None,98 p['port']['id'])99 self._update('routers', r['router']['id'],100 {'router': {'portforwardings': duplicated}},101 expected_code=exc.HTTPBadRequest.code)102 # clean-up103 self._router_interface_action('remove',104 r['router']['id'],105 None,106 p['port']['id'])107 def test_pfwd_update_with_duplicate_outside_port(self):108 duplicated = copy.deepcopy(self.forwardings)109 duplicated[1]['outside_port'] = duplicated[0]['outside_port']110 with self.router() as r:111 with self.subnet(cidr='10.0.0.0/24') as s:112 with self.port(subnet=s, no_delete=True) as p:113 self._router_interface_action('add',114 r['router']['id'],115 None,116 p['port']['id'])117 self._update('routers', r['router']['id'],118 {'router': {'portforwardings': duplicated}},119 expected_code=exc.HTTPBadRequest.code)120 # clean-up121 self._router_interface_action('remove',122 r['router']['id'],123 None,124 p['port']['id'])125 def test_pfwd_delete_rules(self):126 with self.router() as r:127 with self.subnet(cidr='10.0.0.0/24') as s:128 with self.port(subnet=s, no_delete=True) as p:129 self._pfwd_update_prepare(r['router']['id'],130 None, p['port']['id'],131 self.forwardings)132 body = self._update('routers', r['router']['id'],133 {'router': {'portforwardings':134 self.forwardings[0:1]}})135 self.assertEqual(body['router']['portforwardings'],136 self.forwardings[0:1])137 self._pfwd_update_cleanup(p['port']['id'],138 None, r['router']['id'], [])139 def test_pfwd_update_with_nonexist_subnet(self):140 with self.router() as r:141 with self.subnet(cidr='10.0.0.0/24') as s:142 with self.port(subnet=s, no_delete=True) as p:143 self._router_interface_action('add',144 r['router']['id'],145 None,146 p['port']['id'])147 forwardings = [{'outside_port': 2222,148 'inside_addr': '10.1.0.3',149 'inside_port': 22,150 'protocol': 'tcp'151 }]152 self._update('routers', r['router']['id'],153 {'router': {'portforwardings':154 forwardings}},155 expected_code=exc.HTTPBadRequest.code)156 # clean-up157 self._router_interface_action('remove',158 r['router']['id'],159 None,160 p['port']['id'])161 def test_pfwd_update_with_invalid_protocol(self):162 with self.router() as r:163 with self.subnet(cidr='10.0.0.0/24') as s:164 with self.port(subnet=s, no_delete=True) as p:165 self._router_interface_action('add',166 r['router']['id'],167 None,168 p['port']['id'])169 forwardings = [{'outside_port': 2222,170 'inside_addr': '10.0.0.3',171 'inside_port': 22,172 'protocol': 'ppp'173 }]174 self._update('routers', r['router']['id'],175 {'router': {'portforwardings':176 forwardings}},177 expected_code=exc.HTTPBadRequest.code)178 # clean-up179 self._router_interface_action('remove',180 r['router']['id'],181 None,182 p['port']['id'])183 def test_pfwd_update_with_invalid_ip_address(self):184 with self.router() as r:185 with self.subnet(cidr='10.0.0.0/24') as s:186 with self.port(subnet=s, no_delete=True) as p:187 self._router_interface_action('add',188 r['router']['id'],189 None,190 p['port']['id'])191 forwardings = [{'outside_port': 2222,192 'inside_addr': '710.0.0.3',193 'inside_port': 22,194 'protocol': 'tcp'195 }]196 self._update('routers', r['router']['id'],197 {'router': {'portforwardings':198 forwardings}},199 expected_code=exc.HTTPBadRequest.code)200 # clean-up201 self._router_interface_action('remove',202 r['router']['id'],203 None,204 p['port']['id'])205 def test_pfwd_update_with_invalid_port_number(self):206 with self.router() as r:207 with self.subnet(cidr='10.0.0.0/24') as s:208 with self.port(subnet=s, no_delete=True) as p:209 self._router_interface_action('add',210 r['router']['id'],211 None,212 p['port']['id'])213 forwardings = [{'outside_port': -1,214 'inside_addr': '10.0.0.3',215 'inside_port': 22,216 'protocol': 'tcp'217 }]218 self._update('routers', r['router']['id'],219 {'router': {'portforwardings':220 forwardings}},221 expected_code=exc.HTTPBadRequest.code)222 forwardings = [{'outside_port': 65536,223 'inside_addr': '10.0.0.3',224 'inside_port': 22,225 'protocol': 'tcp'226 }]227 self._update('routers', r['router']['id'],228 {'router': {'portforwardings':229 forwardings}},230 expected_code=exc.HTTPBadRequest.code)231 forwardings = [{'outside_port': 2222,232 'inside_addr': '10.0.0.3',233 'inside_port': -1,234 'protocol': 'tcp'235 }]236 self._update('routers', r['router']['id'],237 {'router': {'portforwardings':238 forwardings}},239 expected_code=exc.HTTPBadRequest.code)240 forwardings = [{'outside_port': 2222,241 'inside_addr': '10.0.0.3',242 'inside_port': 65536,243 'protocol': 'tcp'244 }]245 self._update('routers', r['router']['id'],246 {'router': {'portforwardings':247 forwardings}},248 expected_code=exc.HTTPBadRequest.code)249 # clean-up250 self._router_interface_action('remove',251 r['router']['id'],252 None,253 p['port']['id'])254 def test_pfwd_clear_rule_with_None(self):255 with self.router() as r:256 with self.subnet(cidr='10.0.0.0/24') as s:257 with self.port(subnet=s, no_delete=True) as p:258 self._pfwd_update_prepare(r['router']['id'],259 None, p['port']['id'],260 self.forwardings)261 body = self._update('routers', r['router']['id'],262 {'router': {'portforwardings': None}})263 self.assertEqual(body['router']['portforwardings'], [])264 self._pfwd_update_cleanup(p['port']['id'],265 None, r['router']['id'], [])266class PortForwardingsDBIntTestCase(test_l3.L3NatDBIntTestCase,267 PortForwardingsDBTestCaseBase):268 def setUp(self, plugin=None, ext_mgr=None):269 if not plugin:270 plugin = ('neutron.tests.unit.test_extension_portforwardings.'271 'TestPortForwardingsIntPlugin')272 # for these tests we need to enable overlapping ips273 cfg.CONF.set_default('allow_overlapping_ips', True)274 cfg.CONF.set_default('max_routes', 3)275 ext_mgr = PortForwardingsTestExtensionManager()276 super(test_l3.L3BaseForIntTests, self).setUp(plugin=plugin,277 ext_mgr=ext_mgr)278 self.setup_notification_driver()279class PortForwardingsDBIntTestCaseXML(PortForwardingsDBIntTestCase):280 fmt = 'xml'281class PortForwardingsDBSepTestCase(test_l3.L3NatDBSepTestCase,282 PortForwardingsDBTestCaseBase):283 def setUp(self):284 # the plugin without L3 support285 plugin = 'neutron.tests.unit.test_l3_plugin.TestNoL3NatPlugin'286 # the L3 service plugin287 l3_plugin = ('neutron.tests.unit.test_extension_portforwardings.'288 'TestPortForwardingsL3NatServicePlugin')289 service_plugins = {'l3_plugin_name': l3_plugin}290 # for these tests we need to enable overlapping ips291 cfg.CONF.set_default('allow_overlapping_ips', True)292 cfg.CONF.set_default('max_routes', 3)293 ext_mgr = PortForwardingsTestExtensionManager()294 super(test_l3.L3BaseForSepTests, self).setUp(295 plugin=plugin, ext_mgr=ext_mgr,296 service_plugins=service_plugins)297 self.setup_notification_driver()298class PortForwardingsDBSepTestCaseXML(PortForwardingsDBSepTestCase):...

Full Screen

Full Screen

10.05.py

Source:10.05.py Github

copy

Full Screen

1def is_increasing(l):2 for n in range(len(l)-1):3 if l[n+1]>l[n]:4 pass5 else:6 return False7 return True8co2_levels = [ 320.03, 322.16, 328.07, 333.91, 341.47, 348.92, 357.29, 363.77, 371.51, 382.47, 392.95 ] 9print('co2_levels is increasing: {}'.format(is_increasing(co2_levels)))10test_L1 = [ 15, 12, 19, 27, 45 ]11print('test_L1 is increasing: {}'.format(is_increasing(test_L1)))12test_L2 = [ 'arc', 'circle', 'diameter', 'radius', 'volume', 'area' ]13print('test_L2 is increasing: {}'.format(is_increasing(test_L2)))14test_L3 = [ 11, 21, 19, 27, 28, 23, 31, 45 ]...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful