How to use test_normal_call method in uiautomator

Best Python code snippet using uiautomator

test_app.py

Source: test_app.py Github

copy

Full Screen

...97class TestAPIEdge(XXXTestBase):98 def assert_edge_clean(self, edge):99 assert_equal(edge._call_semaphore.counter,100 edge.max_concurrent_calls)101 def test_normal_call(self):102 edge = APIEdge(MockApp(), self.get_settings())103 api = edge.app.api104 call = Call("foo")105 assert_equal(edge.get_call_handler(call), (api, "foo"))106 assert_equal(edge.get_call_handler_method(call, api, "foo"), api.foo)107 edge.execute(call)108 assert_equal(api.foo.call_count, 1)109 self.assert_edge_clean(edge)110 def test_debug_call(self):111 edge = APIEdge(MockApp(), self.get_settings())112 debug_api = edge.app.debug_api113 call = Call("debug.foo")114 edge.execute(call)115 assert_equal(debug_api.foo.call_count, 1)116 assert_equal(edge._call_semaphore, None)117 def test_timeout(self):118 edge = APIEdge(MockApp(), self.get_settings())119 edge.call_timeout = 0.0120 edge.app.api.foo = lambda: gevent.sleep(0.1)121 try:122 edge.execute(Call("foo"))123 raise AssertionError("timeout not raised!")124 except gevent.Timeout:125 pass126 self.assert_edge_clean(edge)127 def test_no_timeout_decorator(self):128 app = MockApp()129 edge = APIEdge(app, self.get_settings())130 app.api.foo = edge.no_timeout(Mock())131 edge.execute(Call("foo"))132 assert_equal(app.api.foo.call_count, 1)133 self.assert_edge_clean(edge)134 def test_semaphore(self):135 edge = APIEdge(MockApp(), self.get_settings())136 api = edge.app.api137 edge.max_concurrent_calls = 1138 in_first_method = Event()139 finish_first_method = Event()140 def first_method():141 in_first_method.set()142 finish_first_method.wait()143 api.first_method = first_method144 in_second_method = Event()145 def second_method():146 in_second_method.set()147 api.second_method = second_method148 gevent.spawn(edge.execute, Call("first_method"))149 in_first_method.wait()150 gevent.spawn(edge.execute, Call("second_method"))151 gevent.sleep(0)152 assert_logged("too many concurrent callers")153 assert not in_second_method.is_set()154 finish_first_method.set()155 in_second_method.wait()156 self.assert_edge_clean(edge)157class TestDebugAPI(XXXTestBase):158 def test_normal_call(self):159 app = DirtApp("test_normal_call", self.get_settings(), [])160 edge = APIEdge(app, app.settings)161 call = Call("debug.status", (), {}, {})162 result = edge.execute(call)163 assert_contains(result, "uptime")164 def test_error_call(self):165 app = DirtApp("test_normal_call", self.get_settings(), [])166 edge = APIEdge(app, app.settings)167 call = Call("debug.ping", (), {"raise_error": True}, {})168 try:169 edge.execute(call)170 raise AssertionError("exception not raised")171 except Exception as e:172 if not str(e).startswith("pong:"):...

Full Screen

Full Screen

test.py

Source: test.py Github

copy

Full Screen

...17 self.assertEqual(expected, actual)18@patch("os.chdir")19@patch("os.system")20class TestAddFile(unittest.TestCase):21 def test_normal_call(self, system_mock, chdir_mock):22 expected_directory = "/​home/​someuser/​somedir"23 expected_cmd = "tar -r --exclude='path' --file=arch f1"24 backup.addFile(expected_directory, "arch", "f1", "--exclude='path'")25 system_mock.assert_called_once_with(expected_cmd)26 chdir_mock.assert_called_once_with(expected_directory)27 def test_no_exclude(self, system_mock, chdir_mock):28 expected_directory = "/​home/​someuser/​somedir"29 expected_cmd = "tar -r --file=arch f1"30 backup.addFile(expected_directory, "arch", "f1", "")31 system_mock.assert_called_once_with(expected_cmd)32 chdir_mock.assert_called_once_with(expected_directory)33@patch("os.path.exists")34@patch("backup.addFile")35@patch("backup.getFilesToCompress")36class TestCompress(unittest.TestCase):37 def test_normal_call(self, getFilesToCompress_mock, addFile_mock, path_exists_mock):38 bu_files = "bu_files"39 target_file_name = "target"40 to_compress = [("/​somedir", "comp")]41 to_exclude = ["excl"]42 getFilesToCompress_mock.return_value = [to_compress, to_exclude]43 to_exclude_str = backup.makeExcludeDir(to_exclude)44 path_exists_mock.return_value = True45 backup.Compress(bu_files, target_file_name)46 addFile_mock.assert_called_once_with(47 to_compress[0][0], target_file_name, to_compress[0][1], to_exclude_str48 )49@patch("os.getcwd")50@patch("datetime.date")51class TestGetDefaultFileName(unittest.TestCase):52 def test_normal_call(self, date_mock, getcwd_mock):53 dir = "/​some/​dir"54 day = datetime.date(1991, 3, 26)55 date_str = str(day.year) + "_" + str(day.month) + "_" + str(day.day)56 date_mock.today.return_value = day57 getcwd_mock.return_value = dir58 expected = "{}/​backup_{}.tar".format(dir, date_str)59 actual = backup.getDefaultFileName()60 self.assertEqual(expected, actual)61if __name__ == "__main__":...

Full Screen

Full Screen

rack.py

Source: rack.py Github

copy

Full Screen

...11 h1 = Class5Server("hostname1.lindenlab.com")12 h2 = Class5Server("hostname2.lindenlab.com")13 rack.insert(h1, 1)14 rack.insert(h2, 2)15 def test_normal_call(self):16 response = self.do_api_call("c2-02-00")17 self.assert_response_code(response, 200)18 self.assertEqual(response.data, [{'serial_number': None, 19 'hostname': 'hostname1.lindenlab.com', 20 'type': 'server'}, 21 {'serial_number': None, 22 'hostname': 'hostname2.lindenlab.com', 23 'type': 'server'}])24 def test_bad_call(self):25 response = self.do_api_call("huh?")26 self.assert_response_code(response, 404)27 28 response = self.do_api_call("huh?", 2)29 self.assert_response_code(response, 400)30class TestGetServerHostnamesInRack(JinxTestCase):31 api_call_path = "/​jinx/​2.0/​get_server_hostnames_in_rack"32 33 def data(self):34 # Populate Clusto 35 ServerClass("Class 5")36 h1 = Class5Server("hostname1.lindenlab.com")37 h2 = Class5Server("hostname2.lindenlab.com")38 rack1 = LindenRack("c3-03-100")39 rack2 = LindenRack("c3-03-200")40 ServerClass("Class 7")41 chassis1 = Class7Chassis()42 chassis2 = Class7Chassis()43 class7_1 = Class7Server("hostname3.lindenlab.com")44 class7_2 = Class7Server("hostname4.lindenlab.com")45 46 chassis1.insert(class7_1)47 chassis2.insert(class7_2)48 rack2.insert(h1, 1)49 rack1.insert(chassis1, [1, 2])50 rack1.insert(chassis2, [3, 4])51 rack1.insert(h2, 5)52 def test_normal_call(self):53 response = self.do_api_call("c3-03-100")54 self.assert_response_code(response, 200)55 self.assertEqual(sorted(response.data), ['hostname2.lindenlab.com', 'hostname3.lindenlab.com', 'hostname4.lindenlab.com'])56 response = self.do_api_call("c3-03-200")57 self.assert_response_code(response, 200)...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Testing Modern Applications With Playwright ????

Web applications continue to evolve at an unbelievable pace, and the architecture surrounding web apps get more complicated all of the time. With the growth in complexity of the web application and the development process, web application testing also needs to keep pace with the ever-changing demands.

Joomla Testing Guide: How To Test Joomla Websites

Before we discuss the Joomla testing, let us understand the fundamentals of Joomla and how this content management system allows you to create and maintain web-based applications or websites without having to write and implement complex coding requirements.

Test Optimization for Continuous Integration

“Test frequently and early.” If you’ve been following my testing agenda, you’re probably sick of hearing me repeat that. However, it is making sense that if your tests detect an issue soon after it occurs, it will be easier to resolve. This is one of the guiding concepts that makes continuous integration such an effective method. I’ve encountered several teams who have a lot of automated tests but don’t use them as part of a continuous integration approach. There are frequently various reasons why the team believes these tests cannot be used with continuous integration. Perhaps the tests take too long to run, or they are not dependable enough to provide correct results on their own, necessitating human interpretation.

7 Skills of a Top Automation Tester in 2021

With new-age project development methodologies like Agile and DevOps slowly replacing the old-age waterfall model, the demand for testing is increasing in the industry. Testers are now working together with the developers and automation testing is vastly replacing manual testing in many ways. If you are new to the domain of automation testing, the organization that just hired you, will expect you to be fast, think out of the box, and able to detect bugs or deliver solutions which no one thought of. But with just basic knowledge of testing, how can you be that successful test automation engineer who is different from their predecessors? What are the skills to become a successful automation tester in 2019? Let’s find out.

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 uiautomator 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