How to use print_response method in Playwright Python

Best Python code snippet using playwright-python

test_show.py

Source:test_show.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# Copyright (c) 2018-2019 Linh Pham3# wwdtm is relased under the terms of the Apache License 2.04"""Testing module for wwdtm.show"""5import json6import mysql.connector7from wwdtm.show import details, info, utility8def test_id_exists(show_id: int,9 database_connection: mysql.connector.connect,10 print_response: bool = False):11 """Testing repsonse from utility.id_exists"""12 response = utility.id_exists(show_id, database_connection)13 assert response14 if print_response:15 print(json.dumps(response, indent=2))16def test_id_not_exists(show_id: int,17 database_connection: mysql.connector.connect,18 print_response: bool = False):19 """Testing repsonse from utility.id_exists with an invalid ID"""20 response = utility.id_exists(show_id, database_connection)21 assert not response22 if print_response:23 print(json.dumps(response, indent=2))24def test_date_exists(show_year: int,25 show_month: int,26 show_day: int,27 database_connection: mysql.connector.connect,28 print_response: bool = False):29 """Testing response from utility.date_exists"""30 response = utility.date_exists(show_year,31 show_month,32 show_day,33 database_connection)34 assert response35 if print_response:36 print(json.dumps(response, indent=2))37def test_date_not_exists(show_year: int,38 show_month: int,39 show_day: int,40 database_connection: mysql.connector.connect,41 print_response: bool = False):42 """Testing response from utility.date_exists with an incorrect date"""43 response = utility.date_exists(show_year,44 show_month,45 show_day,46 database_connection)47 assert not response48 if print_response:49 print(json.dumps(response, indent=2))50def test_retrieve_by_id(show_id: int,51 database_connection: mysql.connector.connect,52 print_response: bool = False):53 """Testing response from info.retrieve_by_id"""54 show_info = info.retrieve_by_id(show_id, database_connection)55 assert show_info is not None56 assert "best_of" in show_info57 assert "repeat_show" in show_info58 if print_response:59 print(json.dumps(show_info, indent=2))60def test_retrieve_by_invalid_id(show_id: int,61 database_connection: mysql.connector.connect,62 print_response: bool = False):63 """Testing response from info.retrieve_by_id with an invalid ID"""64 show_info = info.retrieve_by_id(show_id, database_connection)65 assert show_info is None66 if print_response:67 print(json.dumps(show_info, indent=2))68def test_retrieve_by_date(show_year: int,69 show_month: int,70 show_day: int,71 database_connection: mysql.connector.connect,72 print_response: bool = False):73 """Testing response from info.retrieve_by_date"""74 show_info = info.retrieve_by_date(show_year,75 show_month,76 show_day,77 database_connection)78 assert show_info is not None79 assert "best_of" in show_info80 assert "repeat_show" in show_info81 if print_response:82 print(json.dumps(show_info, indent=2))83def test_retrieve_by_invalid_date(show_year: int,84 show_month: int,85 show_day: int,86 database_connection: mysql.connector.connect,87 print_response: bool = False):88 """Testing response from info.retrieve_by_date with incorrect date"""89 try:90 show_info = info.retrieve_by_date(show_year,91 show_month,92 show_day,93 database_connection)94 assert show_info is None95 if print_response:96 print(json.dumps(show_info, indent=2))97 except ValueError:98 assert True99def test_retrieve_by_date_string(show_date: str,100 database_connection: mysql.connector.connect,101 print_response: bool = False):102 """Testing response from info.retrieve_by_date_string"""103 show_info = info.retrieve_by_date_string(show_date, database_connection)104 assert show_info is not None105 if print_response:106 print(json.dumps(show_info, indent=2))107def test_retrieve_by_invalid_date_string(show_date: str,108 database_connection: mysql.connector.connect,109 print_response: bool = False):110 """Testing response from info.retrieve_by_date_string with an111 incorrect date"""112 try:113 show_info = info.retrieve_by_date_string(show_date, database_connection)114 assert show_info is None115 if print_response:116 print(json.dumps(show_info, indent=2))117 except ValueError:118 assert True119def test_retrieve_months_by_year(show_year: int,120 database_connection: mysql.connector.connect,121 print_response: bool = False):122 """Testing response from info.retrieve_months_by_year"""123 show_months = info.retrieve_months_by_year(show_year,124 database_connection)125 assert show_months is not None126 if print_response:127 print(json.dumps(show_months, indent=2))128def test_retrieve_years(database_connection: mysql.connector.connect,129 print_response: bool = False):130 """Testing response from info.retrieve_years"""131 show_years = info.retrieve_years(database_connection)132 assert show_years is not None133 if print_response:134 print(json.dumps(show_years, indent=2))135def test_retrieve_by_year(show_year: int,136 database_connection: mysql.connector.connect,137 print_response: bool = False):138 """Testing response form info.retrieve_by_year"""139 show_info = info.retrieve_by_year(show_year, database_connection)140 assert show_info is not None141 if print_response:142 print(json.dumps(show_info, indent=2))143def test_retrieve_by_year_month(show_year: int,144 show_month: int,145 database_connection: mysql.connector.connect,146 print_response: bool = False):147 """Testing response form info.retrieve_by_year_month"""148 show_info = info.retrieve_by_year_month(show_year,149 show_month,150 database_connection)151 assert show_info is not None152 if print_response:153 print(json.dumps(show_info, indent=2))154def test_retrieve_all(database_connection: mysql.connector.connect,155 print_response: bool = False):156 """Testing response from info.retrieve_all"""157 show_info = info.retrieve_all(database_connection)158 assert show_info is not None159 if print_response:160 print(json.dumps(show_info, indent=2))161def test_retrieve_all_ids(database_connection: mysql.connector.connect,162 print_response: bool = False):163 """Testing response from info.retrieve_all_ids"""164 show_ids = info.retrieve_all_ids(database_connection)165 assert show_ids is not None166 if print_response:167 print(json.dumps(show_ids, indent=2))168def test_retrieve_all_dates(database_connection: mysql.connector.connect,169 print_response: bool = False):170 """Testing response from info.retrieve_all_dates"""171 show_dates = info.retrieve_all_dates(database_connection)172 assert show_dates is not None173 if print_response:174 print(json.dumps(show_dates, indent=2))175def test_retrieve_all_dates_tuple(database_connection: mysql.connector.connect,176 print_response: bool = False):177 """Testing response from info.retrieve_all_dates_tuple"""178 show_dates = info.retrieve_all_dates_tuple(database_connection)179 assert show_dates is not None180 if print_response:181 print(json.dumps(show_dates, indent=2))182def test_retrieve_scores_by_year(show_year: int,183 database_connection: mysql.connector.connect,184 print_response: bool = False):185 """Testing response from info.retrieve_scores_by_year"""186 show_scores = info.retrieve_scores_by_year(show_year, database_connection)187 assert show_scores is not None188 if print_response:189 print(json.dumps(show_scores, indent=2))190def test_retrieve_all_years_months(database_connection: mysql.connector.connect,191 print_response: bool = False):192 """Testing response from info.retrieve_all_show_years_months"""193 show_years_months = info.retrieve_all_show_years_months(database_connection)194 assert show_years_months is not None195 if print_response:196 print(json.dumps(show_years_months, indent=2))197def test_retrieve_all_years_months_tuple(database_connection: mysql.connector.connect,198 print_response: bool = False):199 """Testing response from info.retrieve_all_show_years_months_tuple"""200 show_years_months = info.retrieve_all_show_years_months_tuple(database_connection)201 assert show_years_months is not None202 if print_response:203 print(json.dumps(show_years_months, indent=2))204def test_retrieve_recent(database_connection: mysql.connector.connect,205 print_response: bool = False):206 """Testing response from info.retrieve_recent"""207 show_info = info.retrieve_recent(database_connection)208 assert show_info is not None209 if print_response:210 print(json.dumps(show_info, indent=2))211def test_retrieve_details_by_id(show_id: int,212 database_connection: mysql.connector.connect,213 print_response: bool = False):214 """Testing response from details.retrieve_by_id"""215 show_details = details.retrieve_by_id(show_id, database_connection)216 assert show_details is not None217 assert "host" in show_details218 assert "scorekeeper" in show_details219 assert "panelists" in show_details220 assert "bluff" in show_details221 assert "guests" in show_details222 assert "description" in show_details223 assert "notes" in show_details224 if print_response:225 print(json.dumps(show_details, indent=2))226def test_retrieve_details_by_invalid_id(show_id: int,227 database_connection: mysql.connector.connect,228 print_response: bool = False):229 """Testing response from details.retrieve_by_id with an230 invalid ID"""231 show_details = details.retrieve_by_id(show_id, database_connection)232 assert show_details is None233 if print_response:234 print(json.dumps(show_details, indent=2))235def test_retrieve_details_by_date(show_year: int,236 show_month: int,237 show_day: int,238 database_connection: mysql.connector.connect,239 print_response: bool = False):240 """Testing response from details.retrieve_by_date"""241 show_details = details.retrieve_by_date(show_year,242 show_month,243 show_day,244 database_connection)245 assert show_details is not None246 assert "host" in show_details247 assert "scorekeeper" in show_details248 assert "panelists" in show_details249 assert "bluff" in show_details250 assert "guests" in show_details251 assert "description" in show_details252 assert "notes" in show_details253 if print_response:254 print(json.dumps(show_details, indent=2))255def test_retrieve_details_by_invalid_date(show_year: int,256 show_month: int,257 show_day: int,258 database_connection: mysql.connector.connect,259 print_response: bool = False):260 """Testing repsonse from details.retrieve_by_date with an incorrect261 date"""262 show_details = details.retrieve_by_date(show_year,263 show_month,264 show_day,265 database_connection)266 assert show_details is None267 if print_response:268 print(json.dumps(show_details, indent=2))269def test_retrieve_details_by_date_string(show_date: str,270 database_connection: mysql.connector.connect,271 print_response: bool = False):272 """Testing repsonse from details.retrieve_by_date_string"""273 show_details = details.retrieve_by_date_string(show_date,274 database_connection)275 assert show_details is not None276 assert "host" in show_details277 assert "scorekeeper" in show_details278 assert "panelists" in show_details279 assert "bluff" in show_details280 assert "guests" in show_details281 assert "description" in show_details282 assert "notes" in show_details283 if print_response:284 print(json.dumps(show_details, indent=2))285def test_retrieve_details_by_invalid_date_string(show_date: str,286 database_connection: mysql.connector.connect,287 print_response: bool = False):288 """Testing response from details.retrieve_by_date_string with289 invalud date string"""290 show_details = details.retrieve_by_date_string(show_date,291 database_connection)292 assert show_details is None293 if print_response:294 print(json.dumps(show_details, indent=2))295def test_retrieve_details_by_year(show_year: int,296 database_connection: mysql.connector.connect,297 print_response: bool = False):298 """Testing response from details.retrieve_by_year"""299 show_details = details.retrieve_by_year(show_year,300 database_connection)301 assert show_details is not None302 if print_response:303 print(json.dumps(show_details, indent=2))304def test_retrieve_details_by_year_month(show_year: int,305 show_month: int,306 database_connection: mysql.connector.connect,307 print_response: bool = False):308 """Testing response from details.retrieve_by_year_month"""309 show_details = details.retrieve_by_year_month(show_year,310 show_month,311 database_connection)312 assert show_details is not None313 if print_response:314 print(json.dumps(show_details, indent=2))315def test_retrieve_all_details(database_connection: mysql.connector.connect,316 print_response: bool = False):317 """Testing response from details.retrieve_all"""318 show_details = details.retrieve_all(database_connection)319 assert show_details is not None320 if print_response:321 print(json.dumps(show_details, indent=2))322def test_retrieve_recent_details(database_connection: mysql.connector.connect,323 print_response: bool = False):324 """Testing response from details.retrieve_recent"""325 show_details = details.retrieve_recent(database_connection)326 assert show_details is not None327 if print_response:...

Full Screen

Full Screen

test_panelist.py

Source:test_panelist.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# Copyright (c) 2018-2019 Linh Pham3# wwdtm is relased under the terms of the Apache License 2.04"""Testing module for wwdtm.panelist"""5import json6import mysql.connector7from wwdtm.panelist import details, info, utility8def test_id_exists(panelist_id: int,9 database_connection: mysql.connector.connect,10 print_response: bool = False):11 """Testing response from utility.id_exists"""12 response = utility.id_exists(panelist_id, database_connection)13 assert response14 if print_response:15 print(json.dumps(response, indent=2))16def test_id_not_exists(panelist_id: int,17 database_connection: mysql.connector.connect,18 print_response: bool = False):19 """Testing response from utility.id_exists"""20 response = utility.id_exists(panelist_id, database_connection)21 assert not response22 if print_response:23 print(json.dumps(response, indent=2))24def test_slug_exists(panelist_slug: str,25 database_connection: mysql.connector.connect,26 print_response: bool = False):27 """Testing response from utility.slug_exists"""28 response = utility.slug_exists(panelist_slug, database_connection)29 assert response30 if print_response:31 print(json.dumps(response, indent=2))32def test_slug_not_exists(panelist_slug: str,33 database_connection: mysql.connector.connect,34 print_response: bool = False):35 """Testing response from utility.slug_exists"""36 response = utility.slug_exists(panelist_slug, database_connection)37 assert not response38 if print_response:39 print(json.dumps(response, indent=2))40def test_retrieve_all(database_connection: mysql.connector.connect,41 print_response: bool = False):42 """Testing response from info.retrieve_all"""43 panelists = info.retrieve_all(database_connection)44 assert panelists is not None45 if print_response:46 print(json.dumps(panelists, indent=2))47def test_retrieve_all_ids(database_connection: mysql.connector.connect,48 print_response: bool = False):49 """Testing response from info.retrieve_all_ids"""50 panelist_ids = info.retrieve_all_ids(database_connection)51 assert panelist_ids is not None52 if print_response:53 print(json.dumps(panelist_ids, indent=2))54def test_retrieve_by_id(panelist_id: int,55 database_connection: mysql.connector.connect,56 print_response: bool = False):57 """Testing response from info.retrieve_by_id"""58 panelist_dict = info.retrieve_by_id(panelist_id, database_connection)59 assert panelist_dict is not None60 assert "id" in panelist_dict61 if print_response:62 print(json.dumps(panelist_dict, indent=2))63def test_retrieve_by_slug(panelist_slug: str,64 database_connection: mysql.connector.connect,65 print_response: bool = False):66 """Testing response from info.retrieve_by_slug"""67 panelist_dict = info.retrieve_by_slug(panelist_slug,68 database_connection)69 assert panelist_dict is not None70 assert "id" in panelist_dict71 if print_response:72 print(json.dumps(panelist_dict, indent=2))73def test_retrieve_details_by_id(panelist_id: int,74 database_connection: mysql.connector.connect,75 print_response: bool = False):76 """Testing response from details.retrieve_by_id"""77 panelist_dict = details.retrieve_by_id(panelist_id,78 database_connection)79 assert panelist_dict is not None80 assert "statistics" in panelist_dict81 assert "bluffs" in panelist_dict82 assert "appearances" in panelist_dict83 if print_response:84 print(json.dumps(panelist_dict, indent=2))85def test_retrieve_details_by_slug(panelist_slug: str,86 database_connection: mysql.connector.connect,87 print_response: bool = False):88 """Testing response from details.retrieve_by_slug"""89 panelist_dict = details.retrieve_by_slug(panelist_slug,90 database_connection)91 assert panelist_dict is not None92 assert "statistics" in panelist_dict93 assert "bluffs" in panelist_dict94 assert "appearances" in panelist_dict95 if print_response:96 print(json.dumps(panelist_dict, indent=2))97def test_retrieve_all_details(database_connection: mysql.connector.connect,98 print_response: bool = False):99 """Testing response from details.retrieve_all"""100 panelists_dict = details.retrieve_all(database_connection)101 assert panelists_dict is not None102 if print_response:103 print(json.dumps(panelists_dict, indent=2))104def test_retrieve_scores_grouped_list_by_id(panelist_id: int,105 database_connection: mysql.connector.connect,106 print_response: bool = False):107 """Testing response from info.retrieve_scores_grouped_list_by_id"""108 score_list = info.retrieve_scores_grouped_list_by_id(panelist_id,109 database_connection)110 assert score_list is not None111 assert "score" in score_list112 assert "count" in score_list113 assert len(score_list["score"]) == len(score_list["count"])114 if print_response:115 print(json.dumps(score_list, indent=2))116def test_retrieve_scores_grouped_list_by_slug(panelist_slug: str,117 database_connection: mysql.connector.connect,118 print_response: bool = False):119 """Testing response from info.retrieve_scores_grouped_list_by_slug"""120 score_list = info.retrieve_scores_grouped_list_by_slug(panelist_slug,121 database_connection)122 assert score_list is not None123 assert "score" in score_list124 assert "count" in score_list125 assert len(score_list["score"]) == len(score_list["count"])126 if print_response:127 print(json.dumps(score_list, indent=2))128def test_retrieve_scores_grouped_ordered_pair_by_id(panelist_id: int,129 database_connection: mysql.connector.connect,130 print_response: bool = False):131 """Testing response from info.retrieve_scores_grouped_ordered_pair_by_id"""132 score_list = info.retrieve_scores_grouped_ordered_pair_by_id(panelist_id,133 database_connection)134 assert score_list is not None135 if print_response:136 print(json.dumps(score_list, indent=2))137def test_retrieve_scores_grouped_ordered_pair_by_slug(panelist_slug: str,138 database_connection: mysql.connector.connect,139 print_response: bool = False):140 """Testing response from info.retrieve_scores_grouped_ordered_pair_by_slug"""141 score_list = info.retrieve_scores_grouped_ordered_pair_by_slug(panelist_slug,142 database_connection)143 assert score_list is not None144 if print_response:145 print(json.dumps(score_list, indent=2))146def test_retrieve_scores_list_by_id(panelist_id: int,147 database_connection: mysql.connector.connect,148 print_response: bool = False):149 """Testing response from info.retrieve_scores_list_by_id"""150 score_list = info.retrieve_scores_list_by_id(panelist_id,151 database_connection)152 assert score_list is not None153 assert "shows" in score_list154 assert "scores" in score_list155 assert len(score_list["shows"]) == len(score_list["scores"])156 if print_response:157 print(json.dumps(score_list, indent=2))158def test_retrieve_scores_list_by_slug(panelist_slug: str,159 database_connection: mysql.connector.connect,160 print_response: bool = False):161 """Testing response from info.retrieve_scores_list_by_slug"""162 score_list = info.retrieve_scores_list_by_slug(panelist_slug,163 database_connection)164 assert score_list is not None165 assert "shows" in score_list166 assert "scores" in score_list167 assert len(score_list["shows"]) == len(score_list["scores"])168 if print_response:169 print(json.dumps(score_list, indent=2))170def test_retrieve_scores_ordered_pair_by_id(panelist_id: int,171 database_connection: mysql.connector.connect,172 print_response: bool = False):173 """Testing response from info.retrieve_scores_ordered_pair_by_id"""174 score_list = info.retrieve_scores_ordered_pair_by_id(panelist_id,175 database_connection)176 assert score_list is not None177 if print_response:178 print(json.dumps(score_list, indent=2))179def test_retrieve_scores_ordered_pair_by_slug(panelist_slug: str,180 database_connection: mysql.connector.connect,181 print_response: bool = False):182 """Testing response from info.retrieve_scores_ordered_pair_by_slug"""183 score_list = info.retrieve_scores_ordered_pair_by_slug(panelist_slug,184 database_connection)185 assert score_list is not None186 if print_response:187 print(json.dumps(score_list, indent=2))188def test_retrieve_yearly_appearances_by_id(panelist_id: int,189 database_connection: mysql.connector.connect,190 print_response: bool = False):191 """Testing response from info.retrieve_yearly_appearances_by_id"""192 appearances = info.retrieve_yearly_appearances_by_id(panelist_id,193 database_connection)194 assert appearances is not None195 if print_response:196 print(json.dumps(appearances, indent=2))197def test_retrieve_yearly_appearances_by_slug(panelist_slug: str,198 database_connection: mysql.connector.connect,199 print_response: bool = False):200 """Testing response from info.retrieve_yearly_appearances_by_slug"""201 appearances = info.retrieve_yearly_appearances_by_slug(panelist_slug,202 database_connection)203 assert appearances is not None204 if print_response:...

Full Screen

Full Screen

BTeeBot.py

Source:BTeeBot.py Github

copy

Full Screen

...19def clean_up_reply(dom):20 remove_whitespace_nodes(dom)21 dom.normalize();22 return dom23def print_response( ret, full = False ):24 # get status and message25 st = int(ret.getElementsByTagName('status')[0].getAttribute('value') );26 msgs = ret.getElementsByTagName('message');27 msg = "" if not msgs else msgs[0].getAttribute('value');28 print ( "Reply is: " + REPLY_STATUSES[st] + " / " + msg)29 # print the whole message30 if(full or st != 10):31 remove_whitespace_nodes(ret)32 ret.normalize();33 print(ret.toprettyxml(indent=" ", newl="\n"));34def extract_items(aItemTagName, aReply):35 clean_up_reply(aReply)36 ret = []37 for obj in aReply.getElementsByTagName(aItemTagName):38 item = {}39 for ch in obj.childNodes:40 # 'value' attribute variant41 item[ch._get_localName()] = ch.getAttribute('value')42 # Tag contents variant below43 #item[ch._get_localName()] = ch.firstChild.nodeValue44 ret.append(item)45 return ret46LAND = ['login','world_name','land_name','granted']47SITE = ['land_name', 'settlement_name']48BUILDING =['buildingclass','buildingname','volume']49HUMAN = ['humanclass','humanname','experience','volume']50RESOURCE =['resourcename','volume']51def extract(tags, elements):52 ret = []53 for obj in elements:54 item = {}55 for tag in tags:56 item[tag] = obj.getElementsByTagName(tag)[0].getAttribute('value')57 ret.append(item)58 return ret59################################################################################60B,H,R = {},{},{}61set_up_consts(MDIR + '/../../TUSCore/GameServer/Configuration/Data/Test',R,B,H)62#63# now use short name to get the object map64# B['farm'] == {'name':'farm', 'class':'regular', ... }65#66# synchronize with modbot, TODO better way67NUMBER_OF_EPOCHS = 168NUMBER_OF_TICKS = 2069SLEEP_BETWEEN_TICKS = 370# Define bot specific "constants".71LOGIN = "btee"72PASSWORD = "bteepasswd"73MODERATED = True74interface = TUSUserInterface(LOGIN, PASSWORD, MODERATED)75# Define names.76WORLD_NAME = "World"77LAND_NAME = "BTee Land"78TICK_LEN = 379SETTLEMENT_NAME = "BTee Settlement"80ID_HOLDER_CLASS_SETTLEMENT = "1" # ????81print ("Creating user")82ret = interface.createUser()83print_response(ret)84print ("Creating land" )85ret = interface.createLand(WORLD_NAME, LAND_NAME)86print_response(ret)87print ("Creating settlement")88ret = interface.createSettlement(LAND_NAME, SETTLEMENT_NAME)89print_response(ret)90print( "Building...")91interface.setCurrentHolder(ID_HOLDER_CLASS_SETTLEMENT, SETTLEMENT_NAME)92ret = interface.build(B['farm'], 2)93print_response(ret)94ret = interface.build(B["sawmill"], 1)95print_response(ret)96ret = interface.build(B["marketplace"], 1)97print_response(ret)98ret = interface.build(B["mine"], 1)99print_response(ret)100ret = interface.build(B["quarry"], 1)101print_response(ret)102ret = interface.build(B["steelworks"], 1)103print_response(ret)104print ("Engaging human")105ret = interface.engage(H["farmer"] , 10)106print_response(ret)107ret = interface.engage(H["lumberjack"] , 5)108print_response(ret)109ret = interface.engage(H["merchant"], 5)110print_response(ret)111ret = interface.engage(H["miner"], 5)112print_response(ret)113ret = interface.engage(H["stone mason"], 5)114print_response(ret)115ret = interface.engage(H["breeder"], 5)116print_response(ret)117ret = interface.engage(H["steelworker"], 1)118print_response(ret)119ret = interface.engage(H["fisherman"], 3)120print_response(ret)121print ("Dismissing jobless")122ret = interface.dismiss( {'key':'workerjoblessnovice'}, 750)123print_response(ret)124# Take a look around125print ("Getting epoch")126ret = interface.getEpoch(WORLD_NAME)127print_response(ret, True)128print ("Getting lands")129ret = interface.getLands()130print_response(ret)131lands = extract(LAND, ret.getElementsByTagName('object'));132for land in lands:133 ret = interface.getLand(land['land_name']);134 print_response(ret)135 ret = interface.getSettlements(land['land_name']);136 print_response(ret)137 sites = extract(SITE, ret.getElementsByTagName('object'))138 land['_sites'] = sites139 for site in sites:140 ret = interface.getSettlement( site['settlement_name'] )141 print_response(ret)142 interface.setCurrentHolder( ID_HOLDER_CLASS_SETTLEMENT, site['settlement_name'])143 ret = interface.listHumans()144 print_response(ret,True);145 humans = extract_items('object', ret)146 site['_humans'] = humans147 for h in humans:148 ret = interface.humanDetails(h)149 print_response(ret)150 ret = interface.listBuildings()151 print_response(ret)152 buildings = extract_items('object', ret);153 site['_buildings'] = buildings154 for b in buildings:155 ret = interface.buildingDetails(b)156 print_response(ret)157 ret = interface.listResources()158 print_response(ret, True)159 resources = extract_items('object',ret)160 site['_resources'] = resources161 for r in resources:162 ret = interface.resourceDetails(r)163 print_response(ret)164from pprint import pprint165pprint( lands, indent=4)166print( "What now?")167def pRVec(aList,aName):168 s = ""169 s += aName + " <- c("170 first = True171 for el in aList:172 if not first:173 s += ", "174 else :175 first = False176 s += str(el)177 s += ")"...

Full Screen

Full Screen

test_location.py

Source:test_location.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# Copyright (c) 2018-2020 Linh Pham3# wwdtm is relased under the terms of the Apache License 2.04"""Testing module for wwdtm.location"""5import json6import mysql.connector7from wwdtm.location import details, info, utility8def test_id_exists(location_id: int,9 database_connection: mysql.connector.connect,10 print_response: bool = False):11 """Testing response from utility.id_exists"""12 response = utility.id_exists(location_id, database_connection)13 assert response14 if print_response:15 print(json.dumps(response, indent=2))16def test_id_not_exists(location_id: int,17 database_connection: mysql.connector.connect,18 print_response: bool = False):19 """Testing response from utility.id_exists"""20 response = utility.id_exists(location_id, database_connection)21 assert not response22 if print_response:23 print(json.dumps(response, indent=2))24def test_slug_exists(location_slug: str,25 database_connection: mysql.connector.connect,26 print_response: bool = False):27 """Testing response from utility.slug_exists"""28 response = utility.slug_exists(location_slug, database_connection)29 assert response30 if print_response:31 print(json.dumps(response, indent=2))32def test_slug_not_exists(location_slug: str,33 database_connection: mysql.connector.connect,34 print_response: bool = False):35 """Testing response from utility.slug_exists"""36 response = utility.slug_exists(location_slug, database_connection)37 assert not response38 if print_response:39 print(json.dumps(response, indent=2))40def test_retrieve_all(database_connection: mysql.connector.connect,41 sort_by_venue: bool = False,42 print_response: bool = False):43 """Testing response from info.retrieve_all"""44 response = info.retrieve_all(database_connection, sort_by_venue)45 assert response is not None46 if print_response:47 print(json.dumps(response, indent=2))48def test_retrieve_all_ids(database_connection: mysql.connector.connect,49 sort_by_venue: bool = False,50 print_response: bool = False):51 """Testing response from info.retrieve_all_ids"""52 response = info.retrieve_all_ids(database_connection, sort_by_venue)53 assert response is not None54 if print_response:55 print(json.dumps(response, indent=2))56def test_retrieve_by_id(location_id: int,57 database_connection: mysql.connector.connect,58 print_response: bool = False):59 """Testing response from info.retrieve_by_id"""60 location_dict = info.retrieve_by_id(location_id, database_connection)61 assert location_dict is not None62 assert "city" in location_dict63 assert "state" in location_dict64 assert "venue" in location_dict65 assert "slug" in location_dict66 if print_response:67 print(json.dumps(location_dict, indent=2))68def test_retrieve_by_slug(location_slug: str,69 database_connection: mysql.connector.connect,70 print_response: bool = False):71 """Testing response from info.retrieve_by_slug"""72 location_dict = info.retrieve_by_slug(location_slug, database_connection)73 assert location_dict is not None74 assert "city" in location_dict75 assert "state" in location_dict76 assert "venue" in location_dict77 assert "slug" in location_dict78 if print_response:79 print(json.dumps(location_dict, indent=2))80def test_retrieve_recordings_by_id(location_id: int,81 database_connection: mysql.connector.connect,82 print_response: bool = False):83 """Testing response from details.retrieve_recordings_by_id"""84 location_dict = details.retrieve_recordings_by_id(location_id,85 database_connection)86 assert location_dict is not None87 assert "recordings" in location_dict88 assert "count" in location_dict["recordings"]89 assert "shows" in location_dict["recordings"]90 if print_response:91 print(json.dumps(location_dict, indent=2))92def test_retrieve_recordings_by_slug(location_slug: str,93 database_connection: mysql.connector.connect,94 print_response: bool = False):95 """Testing response from details.retrieve_recordings_by_slug"""96 location_dict = details.retrieve_recordings_by_slug(location_slug,97 database_connection)98 assert location_dict is not None99 assert "recordings" in location_dict100 assert "count" in location_dict["recordings"]101 assert "shows" in location_dict["recordings"]102 if print_response:103 print(json.dumps(location_dict, indent=2))104def test_retrieve_all_recordings(database_connection: mysql.connector.connect,105 sort_by_venue: bool = False,106 print_response: bool = False):107 """Testing response from details.retrieve_all_recordings"""108 locations_dict = details.retrieve_all_recordings(database_connection,109 sort_by_venue)110 assert locations_dict is not None111 if print_response:...

Full Screen

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Python 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