Best Python code snippet using autotest_python
rpc_interface_unittest.py
Source: rpc_interface_unittest.py
...147 self.assertEquals(test['job_owner'], 'myuser')148 self.assertEquals(test['status'], 'GOOD')149 self.assertEquals(test['hostname'], 'myhost')150 self.assertEquals(test['kernel'], 'mykernel1')151 def test_get_detailed_test_views(self):152 test = rpc_interface.get_detailed_test_views()[0]153 self._check_for_get_test_views(test)154 self.assertEquals(test['attributes'], {'myattr': 'myval',155 'myattr2': 'myval2'})156 self.assertEquals(test['iterations'], [{'attr': {'iattr': 'ival',157 'iattr2': 'ival2'},158 'perf': {'iresult': 1,159 'iresult2': 2}}])160 self.assertEquals(test['labels'], ['testlabel1', 'testlabel2'])161 def test_test_attributes(self):162 rpc_interface.set_test_attribute('foo', 'bar', test_name='mytest1')163 test = rpc_interface.get_detailed_test_views()[0]164 self.assertEquals(test['attributes'], {'foo': 'bar',165 'myattr': 'myval',166 'myattr2': 'myval2'})167 rpc_interface.set_test_attribute('foo', 'goo', test_name='mytest1')168 test = rpc_interface.get_detailed_test_views()[0]169 self.assertEquals(test['attributes'], {'foo': 'goo',170 'myattr': 'myval',171 'myattr2': 'myval2'})172 rpc_interface.set_test_attribute('foo', None, test_name='mytest1')173 test = rpc_interface.get_detailed_test_views()[0]174 self.assertEquals(test['attributes'], {'myattr': 'myval',175 'myattr2': 'myval2'})176 def test_immutable_attributes(self):177 self.assertRaises(ValueError, rpc_interface.set_test_attribute,178 'myattr', 'foo', test_name='mytest1')179 def test_get_test_views(self):180 tests = rpc_interface.get_test_views()181 self.assertEquals(len(tests), 3)182 test = rpc_interface.get_test_views(183 job_name='myjob1', test_name='mytest1')[0]184 self.assertEquals(tests[0], test)185 self._check_for_get_test_views(test)186 self.assertEquals(187 [], rpc_interface.get_test_views(hostname='fakehost'))...
autotest-rpc-query-keyvals
Source: autotest-rpc-query-keyvals
1#!/usr/bin/python2import sys3import optparse4try:5 import autotest.common6except ImportError:7 import common8from autotest.cli import rpc9def parse_options():10 usage = "usage: %prog [options] job_id"11 parser = optparse.OptionParser(usage=usage)12 parser.add_option("-m", "--machine", dest="machine")13 parser.add_option("-t", "--test", dest="test")14 parser.add_option("-T", "--type", dest="type", type="choice",15 choices=["all", "test", "iteration", "attr", "perf"])16 parser.add_option("-k", "--key", dest="key")17 parser.set_defaults(type="all")18 options, args = parser.parse_args()19 options.show_test_keyvals = options.type in ("all", "test")20 options.show_attr_keyvals = options.type in ("all", "iteration", "attr")21 options.show_perf_keyvals = options.type in ("all", "iteration", "perf")22 options.show_iter_keyvals = (23 options.show_perf_keyvals or options.show_attr_keyvals)24 return parser, options, args25def print_keyvals(keyval, format_string, options):26 for key, value in keyval.iteritems():27 if not options.key or key == options.key:28 print format_string % (key, value)29def print_views(test_views, options):30 for view in test_views:31 if not options.machine:32 print "Machine: %s" % view["hostname"]33 if not options.test:34 print "Test: %s" % view["test_name"]35 if options.show_test_keyvals:36 print "Test Attributes:"37 print_keyvals(view["attributes"], "\t%s = %s", options)38 if options.show_iter_keyvals:39 print "Iteration Attributes:"40 for i, iteration in enumerate(view["iterations"]):41 print "\tIteration #%d:" % (i + 1)42 if options.show_attr_keyvals:43 print_keyvals(iteration["attr"], "\t\t%s(attr) = %s",44 options)45 if options.show_perf_keyvals:46 print_keyvals(iteration["perf"], "\t\t%s(perf) = %s",47 options)48 print49def main():50 parser, options, args = parse_options()51 if not args:52 parser.print_help()53 return54 query_filter = {}55 if options.machine:56 query_filter["hostname"] = options.machine57 if options.test:58 query_filter["test_name"] = options.test59 comm = rpc.tko_comm()60 test_views = []61 for job_id in args:62 query_filter["job_tag__startswith"] = "%s-" % job_id63 test_views += comm.run("get_detailed_test_views", **query_filter)64 print_views(test_views, options)65if __name__ == "__main__":...
query_keyvals
Source: query_keyvals
1#!/usr/bin/python2import sys, optparse3import common4from autotest_lib.cli import rpc5def parse_options():6 usage = "usage: %prog [options] job_id"7 parser = optparse.OptionParser(usage=usage)8 parser.add_option("-m", "--machine", dest="machine")9 parser.add_option("-t", "--test", dest="test")10 parser.add_option("-T", "--type", dest="type", type="choice",11 choices=["all", "test", "iteration", "attr", "perf"])12 parser.add_option("-k", "--key", dest="key")13 parser.set_defaults(type="all")14 options, args = parser.parse_args()15 options.show_test_keyvals = options.type in ("all", "test")16 options.show_attr_keyvals = options.type in ("all", "iteration", "attr")17 options.show_perf_keyvals = options.type in ("all", "iteration", "perf")18 options.show_iter_keyvals = (19 options.show_perf_keyvals or options.show_attr_keyvals)20 return parser, options, args21def print_keyvals(keyval, format_string, options):22 for key, value in keyval.iteritems():23 if not options.key or key == options.key:24 print format_string % (key, value)25def print_views(test_views, options):26 for view in test_views:27 if not options.machine:28 print "Machine: %s" % view["hostname"]29 if not options.test:30 print "Test: %s" % view["test_name"]31 if options.show_test_keyvals:32 print "Test Attributes:"33 print_keyvals(view["attributes"], "\t%s = %s", options)34 if options.show_iter_keyvals:35 print "Iteration Attributes:"36 for i, iteration in enumerate(view["iterations"]):37 print "\tIteration #%d:" % (i + 1)38 if options.show_attr_keyvals:39 print_keyvals(iteration["attr"], "\t\t%s(attr) = %s",40 options)41 if options.show_perf_keyvals:42 print_keyvals(iteration["perf"], "\t\t%s(perf) = %s",43 options)44 print45def main():46 parser, options, args = parse_options()47 if not args:48 parser.print_help()49 return50 query_filter = {}51 if options.machine:52 query_filter["hostname"] = options.machine53 if options.test:54 query_filter["test_name"] = options.test55 comm = rpc.tko_comm()56 test_views = []57 for job_id in args:58 query_filter["job_tag__startswith"] = "%s-" % job_id59 test_views += comm.run("get_detailed_test_views", **query_filter)60 print_views(test_views, options)61if __name__ == "__main__":...
Check out the latest blogs from LambdaTest on this topic:
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.
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!!