How to use get_raw method in Airtest

Best Python code snippet using Airtest

client_test.py

Source:client_test.py Github

copy

Full Screen

...81 with self.assertRaises(ParameterError):82 self.client.get(url=self.correct_url)83 def test_empty_url(self):84 with self.assertRaises(ParameterError):85 self.client.get_raw()86 def test_empty_api_key(self):87 with self.assertRaises(ParameterError):88 client = Client('')89 client.get_raw(url=self.correct_url)90 def test_incorrect_api_key(self):91 client = Client('at_00000000000000000000000000000')92 with self.assertRaises(ApiAuthError):93 client.get_raw(url=self.correct_url)94 def test_raw_data(self):95 response = self.client.get_raw(96 url=self.correct_url,97 image_output_format=self.correct_image_output_format98 )99 self.assertTrue(response.startswith(b"data:image/jpeg;base64"))100 def test_raw_data_error(self):101 with self.assertRaises(HttpApiError) as error:102 self.client.get_raw(103 url=self.unreachable_url,104 output_format=Client.XML_FORMAT105 )106 self.assertTrue(error.startswith(b'<?xml'))107 def test_incorrect_cookies(self):108 with self.assertRaises(ParameterError):109 self.client.get_raw(110 url=self.correct_url,111 cookies=self.incorrect_cookies112 )113 def test_incorrect_filename(self):114 with self.assertRaises(FileError):115 self.client.get(116 filename=self.incorrect_filename,117 url=self.correct_url,118 )119 def test_incorrect_credits(self):120 with self.assertRaises(ParameterError):121 self.client.get_raw(122 url=self.correct_url,123 credits='NULL'124 )125 def test_incorrect_image_output_format(self):126 with self.assertRaises(ParameterError):127 self.client.get_raw(128 url=self.correct_url,129 image_output_format='aaa'130 )131 def test_incorrect_type(self):132 with self.assertRaises(ParameterError):133 self.client.get_raw(134 url=self.correct_url,135 type='test'136 )137 def test_incorrect_quality(self):138 with self.assertRaises(ParameterError):139 self.client.get_raw(140 url=self.correct_url,141 quality=150142 )143 def test_incorrect_width(self):144 with self.assertRaises(ParameterError):145 self.client.get_raw(146 url=self.correct_url,147 width=Client.MAX_SIZE + 100148 )149 def test_incorrect_height(self):150 with self.assertRaises(ParameterError):151 self.client.get_raw(152 url=self.correct_url,153 height=Client.MAX_SIZE + 100154 )155 def test_incorrect_thumb_width(self):156 with self.assertRaises(ParameterError):157 self.client.get_raw(158 url=self.correct_url,159 thumb_width=Client.MIN_THUMB_WIDTH - 1160 )161 def test_incorrect_thumb_width_with_width(self):162 with self.assertRaises(ParameterError):163 self.client.get_raw(164 url=self.correct_url,165 width=self.correct_size,166 thumb_width=self.correct_size + 1167 )168 def test_incorrect_mode(self):169 with self.assertRaises(ParameterError):170 self.client.get_raw(171 url=self.correct_url,172 mode='aaa'173 )174 def test_incorrect_scroll(self):175 with self.assertRaises(ParameterError):176 self.client.get_raw(177 url=self.correct_url,178 scroll=123179 )180 def test_incorrect_full_page(self):181 with self.assertRaises(ParameterError):182 self.client.get_raw(183 url=self.correct_url,184 full_page=123185 )186 def test_incorrect_no_js(self):187 with self.assertRaises(ParameterError):188 self.client.get_raw(189 url=self.correct_url,190 no_js=123191 )192 def test_incorrect_delay(self):193 with self.assertRaises(ParameterError):194 self.client.get_raw(195 url=self.correct_url,196 delay=Client.MAX_DELAY + 1197 )198 def test_incorrect_timeout(self):199 with self.assertRaises(ParameterError):200 self.client.get_raw(201 url=self.correct_url,202 timeout=Client.MAX_TIMEOUT + 1203 )204 def test_incorrect_scale(self):205 with self.assertRaises(ParameterError):206 self.client.get_raw(207 url=self.correct_url,208 scale=Client.MIN_SCALE - 0.01209 )210 def test_incorrect_retina(self):211 with self.assertRaises(ParameterError):212 self.client.get_raw(213 url=self.correct_url,214 retina='a'215 )216 def test_incorrect_ua(self):217 with self.assertRaises(ParameterError):218 self.client.get_raw(219 url=self.correct_url,220 ua=False221 )222 def test_incorrect_mobile(self):223 with self.assertRaises(ParameterError):224 self.client.get_raw(225 url=self.correct_url,226 mobile='False'227 )228 def test_incorrect_touch_screen(self):229 with self.assertRaises(ParameterError):230 self.client.get_raw(231 url=self.correct_url,232 touch_screen=10233 )234 def test_incorrect_landscape(self):235 with self.assertRaises(ParameterError):236 self.client.get_raw(237 url=self.correct_url,238 landscape=None239 )240 def test_incorrect_fail_on_hostname_change(self):241 with self.assertRaises(ParameterError):242 self.client.get_raw(243 url=self.correct_url,244 fail_on_hostname_change=500245 )246 def test_incorrect_url(self):247 with self.assertRaises(ParameterError):248 self.client.get_raw(url=self.incorrect_url)249 def test_output(self):250 with self.assertRaises(ParameterError):251 self.client.get(252 filename=self.correct_filename,253 url=self.correct_url,254 response_format='yaml'255 )256if __name__ == '__main__':...

Full Screen

Full Screen

challonge.py

Source:challonge.py Github

copy

Full Screen

...16 self.api_key = os.environ.get('CHALLONGE_KEY')17 self.api_key_dict = {'api_key': self.api_key}18 self.tournament_id = tournament_id19 self.raw_dict = None20 self.get_raw()21 def get_raw(self):22 if self.raw_dict is not None:23 return self.raw_dict24 self.raw_dict = {}25 for key, url in URLS.items():26 url = url % self.tournament_id27 self.raw_dict[key] = self._check_for_200(28 requests.get(url, params=self.api_key_dict)).json()29 return self.raw_dict30 def get_url(self):31 return self.get_raw()['tournament']['tournament']['full_challonge_url']32 def get_name(self):33 return self.get_raw()['tournament']['tournament']['name'].strip()34 def get_date(self):35 return iso8601.parse_date(self.get_raw()['tournament']['tournament']['created_at'])36 def _human_round_names(self, matches):37 """Convert round names from numbers into strings like WQF and LF."""38 last_round = matches[-1]['round']39 SUFFIXES = ['GF', 'F', 'SF', 'QF']40 rounds = {}41 for i, finals in enumerate(SUFFIXES):42 rounds[last_round-i] = finals43 for i, finals in enumerate(SUFFIXES[1:]):44 rounds[-(last_round-i)-1] = finals45 reset = matches[-1]['round'] == matches[-2]['round']46 reset_count = 147 for m in matches:48 r = m['round']49 name = 'W' if r > 0 else 'L'50 if r not in rounds:51 name = '{}R{}'.format(name, abs(r))52 else:53 if rounds[r] != 'GF':54 name += rounds[r]55 else:56 name = 'GF'57 if reset:58 name += str(reset_count)59 reset_count += 160 m['round'] = name61 def get_matches(self):62 # sometimes challonge seems to use the "group_player_ids" parameter of "participant" instead63 # of the "id" parameter of "participant" in the "matches" api.64 # not sure exactly when this happens, but the following code checks for both65 player_map = dict()66 for p in self.get_raw()['participants']:67 if p['participant'].get('name'):68 player_name = p['participant']['name'].strip()69 else:70 player_name = p['participant'].get('username', '<unknown>').strip()71 player_map[p['participant'].get('id')] = player_name72 if p['participant'].get('group_player_ids'):73 for gpid in p['participant']['group_player_ids']:74 player_map[gpid] = player_name75 matches = []76 for m in self.get_raw()['matches']:77 m = m['match']78 set_count = m['scores_csv']79 winner_id = m['winner_id']80 loser_id = m['loser_id']81 round_num = m['round']82 if winner_id is not None and loser_id is not None:83 winner = player_map[winner_id]84 loser = player_map[loser_id]85 # TODO db object here?86 match_result = {'winner': winner, 'loser': loser, 'round': round_num}87 matches.append(match_result)88 self._human_round_names(matches)89 return matches90 def get_players(self):91 return [p['participant']['name'].strip()92 if p['participant']['name'] else p['participant']['username'].strip()93 for p in self.get_raw()['participants']]94 def _check_for_200(self, response):95 response.raise_for_status()...

Full Screen

Full Screen

debug_mutableint.py

Source:debug_mutableint.py Github

copy

Full Screen

...17#18#print('---')19#a = MutableInt(0)20#mutable_int_utils.print_int_info(a)21#get_raw(a, 'a')22#print('---')23#mutable_int_utils.copy_int(a,6)24#mutable_int_utils.print_int_info(a)25#get_raw(a, 'a')26#print('---')27#mutable_int_utils.copy_int(a,100000)28#mutable_int_utils.print_int_info(a)29#get_raw(a, 'a')30#print('---')31#mutable_int_utils.copy_int(a,-1)32#mutable_int_utils.print_int_info(a)33#get_raw(a, 'a')34#print('---')35#mutable_int_utils.copy_int(a,-200)36#mutable_int_utils.print_int_info(a)37#get_raw(a, 'a')38#print('---')39#a = 040#mutable_int_utils.print_int_info(a)41#get_raw(a, 'a')42#b = MutableInt(0)43#mutable_int_utils.print_int_info(b)44#get_raw(b, 'b')45#mutable_int_utils.copy_int(b,a)46#47#print(b+5)48#print(5+b)49#50#mutable_int_utils.print_int_info(b)51#get_raw(b, 'b')52#mutable_int_utils.copy_int(b,-0x87654321)53#mutable_int_utils.print_int_info(b)54#get_raw(b, 'b')55#b.set(0x98765432)56#mutable_int_utils.print_int_info(b)57#get_raw(b, 'b')58#59#print(b+5)60#print(5+b)61#62#print('---')63#c = MutableInt(-10)64##mutable_int_utils.print_int_info(c)65#mutable_int_utils.copy_int(c,-10)66#mutable_int_utils.print_int_info(c)67#get_raw(c, 'c')68#mutable_int_utils.copy_int(c,0)69#mutable_int_utils.print_int_info(c)70#get_raw(c, 'c')71#mutable_int_utils.copy_int(c,1)72#print(c+5)73#print(5+c)74#75#x1 = MutableInt(0)76#x2 = MutableInt(0)77#x3 = MutableInt(0)78#x4 = MutableInt(0)79#x5 = MutableInt(0)80#x6 = MutableInt(0)81if __name__ == '__main__':...

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