Best Python code snippet using localstack_python
topo.py
Source:topo.py
...54 disable_nic_checksum(host, h_if)55 # we want complete control over these actions56 self.router.cmd('echo "0" > /proc/sys/net/ipv4/ip_forward')57 self.router.cmd('echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all')58 def add_default_routes(self):59 for i, host in enumerate(self.hosts):60 ip = info.get("router_ip", i)61 host.cmd("ip route add default via {}".format(ip))62 def add_hosts_entries(self):63 for host in self.hosts:64 for j in range(len(self.hosts)):65 ip = info.get("host_ip", j)66 host.cmd("echo '{} h{}' >> /etc/hosts".format(ip, j))67 def setup(self):68 self.disable_unneeded()69 self.setup_ifaces()70 self.setup_macs()71 self.add_hosts_entries()72 self.add_default_routes()73 def start_router(self):74 self.router.cmd("./router > {} 2>&1 &".format(info.LOGFILE))75 def run_test(self, testname):76 test = tests.TESTS[testname]77 for hp in test.hosts_p:78 h = self.net.get(info.get("host_name", hp))79 cmd = "python ./checker.py \80 --passive \81 --testname={} \82 --host={}".format(testname, hp)83 self.hosts[hp].sendCmd(cmd)84 for ha in test.hosts_a:85 cmd = "python ./checker.py \86 --active \...
util.py
Source:util.py
...11# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN12# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT13# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.14import requestbuilder15def add_default_routes(arglike_obj, default_routes):16 if isinstance(arglike_obj, requestbuilder.Arg):17 if arglike_obj.routes is None:18 arglike_obj.routes = default_routes19 elif isinstance(arglike_obj, list):20 # Note that MutuallyExclusiveArgList is a list21 for item in arglike_obj:22 add_default_routes(item, default_routes)23def aggregate_subclass_fields(cls, field_name):24 values = []25 # pylint doesn't know about classes' built-in mro() method26 # pylint: disable=E110127 for m_class in cls.mro():28 # pylint: enable=E110129 if field_name in vars(m_class):30 values.extend(getattr(m_class, field_name))...
app.py
Source:app.py
...21 return {**health_message, "db": "error"}22 return health_message232425def add_default_routes(app: FastAPI) -> FastAPI:26 app.add_route("/", index, methods=["GET"], include_in_schema=False)27 app.add_route("/health", healthcheck, methods=["GET"], include_in_schema=False)2829 return app303132def create_app() -> FastAPI:33 app = FastAPI(title="Weather Notifier", version="0.1.0")34 app.include_router(subscriptions_router)35 add_default_routes(app)
...
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!!