How to use add_selector method in autotest

Best Python code snippet using autotest_python

data_base_manager.py

Source:data_base_manager.py Github

copy

Full Screen

...18 Renvoie le dataframe contenant l'id, le groupe et le mot de passe associer a chaque utilisateur19 """20 request = (21 Request(distinct=True)22 .add_selector("client.{}".format(config["table"]["client"]["groupe"]), "id")23 .add_selector(24 "client.{}".format(config["table"]["client"]["mot_de_passe"]), "pwd"25 )26 .add_table(config["table"]["client"]["nom_table"], "client")27 .add_condition(28 Condition("client.{} = 1".format(config["table"]["client"]["acces"]), "AND")29 )30 )31 data: pd.DataFrame = request.run(conn2)32 return data33# DEPRECIATED34def get_client_name_from_ref(ref: str) -> str:35 """Documentation36 A partir d'un ref client renvoie l'Intitule du client correspondant37 Parametre:38 ref: référence du client39 Sortie:40 L'intitule du client41 """42 data: pd.DataFrame = pd.read_sql_query(43 "select client.[NOM CLIENT FACTURE] NOM from "44 + config["table"]["client"]["nom_table"]45 + " client "46 + " where '"47 + ref48 + "' = client.[N° CLIENT FACTURE]",49 conn2,50 )51 if len(list(data["NOM"])) == 0:52 print(53 "ERROR client pas dans la table permettant les jointures (ref: " + ref + ")"54 )55 return None56 return str(list(data["NOM"])[0])57def get_id_cpt(58 client: Union[str, None] = None,59 type_energie: Union[str, None] = None,60 name_bat: Union[str, None] = None,61 group: Union[str, None] = None,62) -> List[str]:63 """Documentation64 Parametre:65 client: l'intitule du client ([NOM CLIENT FACTURE]), du compte connecté s'il doit être restreint66 Sortie:67 la liste des id des compteurs68 """69 if client is None and type_energie is None and name_bat is None and group is None:70 request = (71 Request(distinct=True)72 .add_selector(73 "histo.{}".format(config["table"]["histo"]["id_cpt"]), "Id_CPT"74 )75 .add_table(config["table"]["histo"]["nom_table"], "histo")76 .set_order_by("Id_CPT")77 )78 data: pd.DataFrame = request.run(conn)79 return list(data["Id_CPT"])80 request = (81 Request(distinct=True)82 .add_selector("cpt.{}".format(config["table"]["compteur"]["id_cpt"]), "Id_CPT")83 .add_table(config["table"]["compteur"]["nom_table"], "cpt")84 .set_order_by("Id_CPT")85 )86 if client is not None or group is not None:87 # Lien entre la table cpt et client88 request.add_table(89 config["table"]["client"]["nom_table"], "client"90 ).add_condition(91 Condition(92 "cpt.{} = client.{}".format(93 config["table"]["compteur"]["id_client"],94 config["table"]["client"]["id"],95 ),96 "AND",97 ),98 )99 # Condition sur le groupe100 if group is not None:101 request.add_condition(102 Condition(103 "client.{} = '{}'".format(config["table"]["client"]["groupe"], group),104 "AND",105 )106 )107 # Condition sur le client108 if client is not None:109 request.add_condition(110 Condition(111 "client.{} = '{}'".format(config["table"]["client"]["nom"], client),112 "AND",113 )114 )115 # Condition sur le type d'énergie116 if type_energie is not None:117 request.add_condition(118 Condition(119 "cpt.{} = '{}'".format(120 config["table"]["compteur"]["type_energie"], type_energie121 ),122 "AND",123 )124 )125 if name_bat is not None:126 # Jointure des tables batiment et compteur127 # request.add_table(config["table"]["batiment"]["nom_table"], "bat")128 # request.add_condition(129 # Condition(130 # "cpt.{} = bat.{}".format(131 # config["table"]["compteur"]["nom_batiment"],132 # config["table"]["batiment"]["nom"],133 # ),134 # "AND",135 # )136 # )137 request.add_condition(138 Condition(139 "cpt.{} = '{}'".format(140 config["table"]["compteur"]["nom_batiment"], name_bat141 )142 )143 )144 data: pd.DataFrame = request.run(conn2)145 return list(data["Id_CPT"])146def get_groupe() -> List[str]:147 """Documentation148 Récupère la liste des groupes149 """150 request: Request = (151 Request(distinct=True)152 .add_selector("client.{}".format(config["table"]["client"]["groupe"]), "groupe")153 .add_table(config["table"]["client"]["nom_table"], "client")154 .set_order_by("groupe")155 )156 data: pd.DataFrame = request.run(conn)157 return list(data["groupe"])158def get_client(159 id_cpt: Union[str, None] = None,160 name_bat: Union[str, None] = None,161 type_energie: Union[str, None] = None,162 group: Union[str, None] = None,163) -> List[str]:164 """Documentation165 Récupère la liste des clients en fonction du groupe sélectionné166 """167 request: Request = (168 Request(distinct=True)169 .add_selector(170 "client.{}".format(config["table"]["client"]["nom"]), "Nom_Client"171 )172 .add_table(config["table"]["client"]["nom_table"], "client")173 .set_order_by("Nom_Client")174 )175 if group is not None:176 request.add_condition(177 Condition(178 "client.{} = '{}'".format(config["table"]["client"]["groupe"], group),179 "AND",180 )181 )182 data: pd.DataFrame = request.run(conn2)183 return list(data["Nom_Client"])184def get_type_energie(185 id_cpt: Union[str, None] = None,186 name_bat: Union[str, None] = None,187 name_client: Union[str, None] = None,188) -> List[str]:189 """Documentation190 On selectionne les types d'energie sans prendre en considération les autres filtres191 """192 request: Request = (193 Request(distinct=True)194 .add_selector(195 "cpt.{}".format(config["table"]["compteur"]["type_energie"]), "Type_Energie"196 )197 .add_table(config["table"]["compteur"]["nom_table"], "cpt")198 .set_order_by("Type_Energie")199 )200 data: pd.DataFrame = request.run(conn2)201 return list(data["Type_Energie"])202def get_batiment(203 id_cpt: Union[str, None] = None,204 type_energie: Union[str, None] = None,205 name_client: Union[str, None] = None,206 group: Union[str, None] = None,207) -> List[str]:208 """Documentation209 Récupère les noms de batiments en fonction du groupe et des clients sélectionnés210 """211 request: Request = (212 Request(distinct=True)213 .add_selector(214 "bat.{}".format(config["table"]["batiment"]["nom"]), "Nom_Batiment"215 )216 .add_table(config["table"]["batiment"]["nom_table"], "bat")217 .set_order_by("Nom_Batiment")218 )219 if group is not None or name_client is not None:220 # Ajout de la jointure entre les deux tables221 request.add_table(222 config["table"]["client"]["nom_table"], "client"223 ).add_condition(224 Condition(225 "bat.{} = client.{}".format(226 config["table"]["batiment"]["ref_client"],227 config["table"]["client"]["ref"],228 ),229 "AND",230 ),231 )232 if group is not None:233 request.add_condition(234 Condition(235 "client.{} = '{}'".format(config["table"]["client"]["groupe"], group)236 )237 )238 if name_client is not None:239 request.add_condition(240 Condition(241 "client.{} = '{}'".format(config["table"]["client"]["nom"], name_client)242 )243 )244 data: pd.DataFrame = request.run(conn2)245 return list(data["Nom_Batiment"])246def get_data(247 id_cpt: List[str], startDate: datetime.datetime, endDate: datetime.datetime248) -> pd.DataFrame:249 """Documentation250 A partir d'une paire de date, d'un id de capteur, cette fonction va interroger la base de donneée251 Parametre:252 id_cpt: une list d'id de compteur253 startDate: une date de départ254 endDate: une date d'arrive > startDate255 Sortie:256 data: DataFrame contenant les valeurs des compteurs et tout autres informations257 """258 if type(id_cpt) != list:259 id_cpt = [id_cpt]260 request: Request = (261 Request()262 .add_selector("*")263 .add_table(config["table"]["histo"]["nom_table"])264 .add_condition(265 Condition(266 "{} >= '{}'".format(267 config["table"]["histo"]["temps"], startDate.strftime("%d/%m/%Y")268 )269 )270 )271 .add_condition(272 Condition(273 "{} <= '{}'".format(274 config["table"]["histo"]["temps"], endDate.strftime("%d/%m/%Y")275 )276 )277 )278 .add_condition(279 Condition(280 "{} in ('{}')".format(281 config["table"]["histo"]["id_cpt"], "','".join(id_cpt)282 )283 )284 )285 .set_order_by(286 "{}, {}".format(287 config["table"]["histo"]["temps"], config["table"]["histo"]["id_cpt"]288 )289 )290 )291 data: pd.DataFrame = request.run(conn)292 return data293# Obselete294def get_conso(295 id_cpt: List[str],296 startDate: datetime.datetime,297 endDate: datetime.datetime,298 periode: str,299) -> pd.DataFrame:300 """Documentation301 A partir d'une paire de date, d'une periode, d'un id de capteur cette fonction va calculer la consomation302 Parameter:303 id_cpt: list des id des compteurs304 start_date: une date départ305 end_date: une date d'arrive > start_date306 periode: Valeur prédéfini d'une periode sur laquel est calculé les consommation (ex: jours, trim, an, ...)307 Sortie:308 data: DataFrame contenant les consommations associées aux compteurs309 """310 # TODO Changer les requetes par de simple requetes sur des vues311 # Voir pour le calul de la conso312 # Requete conso par jour313 if periode == "jour":314 data: pd.DataFrame = pd.read_sql_query(315 "select vc1.Id_CPT, datefromparts(YEAR(vc2.TS), MONTH(vc2.TS), DAY(vc2.TS)) TS, SUM(vc2.Value - vc1.Value) Conso"316 " from"317 " v_conso vc1,"318 " v_conso vc2"319 " where"320 " vc1.Id_CPT in " + "('" + "','".join(id_cpt) + "')"321 " and vc1.TS >= '"322 + startDate.strftime("%d/%m/%Y")323 + "' and vc1.TS <= '"324 + endDate.strftime("%d/%m/%Y")325 + "' and vc1.Id_CPT = vc2.Id_CPT"326 " and vc1.Num = vc2.Num - 1"327 " group by vc1.Id_CPT, datefromparts(YEAR(vc2.TS), MONTH(vc2.TS), DAY(vc2.TS))"328 " order by vc1.Id_CPT, datefromparts(YEAR(vc2.TS), MONTH(vc2.TS), DAY(vc2.TS))",329 con=conn,330 )331 # Requete conso par mois332 if periode == "mois":333 data: pd.DataFrame = pd.read_sql_query(334 "select vc1.Id_CPT, datefromparts(YEAR(vc2.TS), MONTH(vc2.TS), 1) TS, SUM(vc2.Value - vc1.Value) Conso"335 " from"336 " v_conso vc1,"337 " v_conso vc2"338 " where"339 " vc1.Id_CPT in " + "('" + "','".join(id_cpt) + "')"340 " and vc1.TS >= '"341 + startDate.strftime("%d/%m/%Y")342 + "' and vc1.TS <= '"343 + endDate.strftime("%d/%m/%Y")344 + "' and vc1.Id_CPT = vc2.Id_CPT"345 " and vc1.Num = vc2.Num - 1"346 " group by vc1.Id_CPT, datefromparts(YEAR(vc2.TS), MONTH(vc2.TS), 1)"347 " order by vc1.Id_CPT, datefromparts(YEAR(vc2.TS), MONTH(vc2.TS), 1)",348 con=conn,349 )350 # Requete pour la consomation par trimestre351 if periode == "trim":352 data: pd.DataFrame = pd.read_sql_query(353 "select vc1.Id_CPT, YEAR(vc2.TS) + MONTH(vc2.TS) / 3 / 10. TS, SUM(vc2.Value - vc1.Value) Conso"354 " from"355 " v_conso vc1,"356 " v_conso vc2"357 " where"358 " vc1.Id_CPT in " + "('" + "','".join(id_cpt) + "')"359 " and vc1.TS >= '"360 + startDate.strftime("%d/%m/%Y")361 + "' and vc1.TS <= '"362 + endDate.strftime("%d/%m/%Y")363 + "' and vc1.Id_CPT = vc2.Id_CPT"364 " and vc1.Num = vc2.Num - 1"365 " group by vc1.Id_CPT, YEAR(vc2.TS) + MONTH(vc2.TS) / 3 / 10."366 " order by vc1.Id_CPT, YEAR(vc2.TS) + MONTH(vc2.TS) / 3 / 10.",367 con=conn,368 )369 if periode == "sge":370 pass371 # print(data)372 return data373FACTURATION_DATE: pd.DataFrame = None374def get_facturation_date() -> pd.DataFrame:375 """Documentation376 Cette fonction renvoies les dates de facturation,377 elles sont récupéré de la BD une fois à chaque redémarage de l'application378 Sortie:379 FACTURATION_DATE: Liste des dates de facturation380 """381 global FACTURATION_DATE382 if FACTURATION_DATE is None:383 request: Request = (384 Request()385 .add_selector(386 "Year({})".format(config["table"]["base_temps"]["date"]), "Annee"387 )388 .add_selector(389 "Month({})".format(config["table"]["base_temps"]["date"]), "Mois"390 )391 .add_selector(392 "Day({})".format(config["table"]["base_temps"]["date"]), "Jour"393 )394 .add_table(config["table"]["base_temps"]["nom_table"])395 .add_condition(396 Condition(397 "{} = '{}'".format(398 config["table"]["base_temps"]["type"], "date facturation"399 )400 )401 )402 .set_order_by(config["table"]["base_temps"]["date"])403 )404 data: pd.DataFrame = request.run(conn)405 data = data.apply(pd.to_numeric)...

Full Screen

Full Screen

main_window.py

Source:main_window.py Github

copy

Full Screen

...38 self.setLayout(self.layout)39 self.setWindowTitle("Image finder")40 self.show()41 def add_filter_selectors(self):42 self.add_selector(43 'File format',44 SelectFormatWindow(lambda x: self.model.update_filters('format', x)),45 100,46 False,47 'format',48 )49 self.add_selector(50 'Animal',51 SelectAnimalWindow(lambda x: self.model.update_filters('animal', x)),52 150,53 True,54 'animal',55 )56 self.add_selector(57 'Style',58 SelectStyleWindow(lambda x: self.model.update_filters('style', x)),59 200,60 False,61 'style',62 )63 self.add_selector(64 'Body parts',65 SelectBodyWindow(lambda x: self.model.update_filters('body', x)),66 250,67 True,68 'body',69 )70 def add_selector(self, label, window, ay, with_weight, model_label):71 widget = FilterSelectorWidget(72 label,73 window,74 ay,75 with_weight,76 lambda x: self.set_weight(model_label, x),77 model_label,78 self,79 )80 self.widgets.append(widget)81 self.layout.addWidget(widget)82 def add_results_presentation_selector(self):83 combo_box = QComboBox(self)84 for pres in [p for p in ResultsPresentation]:...

Full Screen

Full Screen

menu.py

Source:menu.py Github

copy

Full Screen

...12 assert 'select_level_cb' in cb_list13 level_list = get_level_list()14 map_list = get_map_list()15 assert len(level_list) > 0# and len(map_list) > 016 level_selector = self.menu.add_selector('', level_list, onchange=cb_list['select_level_cb'])17 # Set default level, maybe a litte hack here18 cb_list['select_level_cb'](*level_list[level_selector.get_value()[1]])19 # map_selector = self.menu.add_selector('', level_list, onchange=cb_list['select_level_cb'])20 # # Set default level, maybe a litte hack here21 # cb_list['select_level_cb'](*level_list[level_selector.get_value()[1]])22 self.menu.add_button('Quit', pygame_menu.events.EXIT)23 def add_level(self, level_list, cb):24 self.menu.add_selector('Level :' , level_list, on_change=cb)25 26 def add_map(self, map_list, cb):27 self.menu.add_selector('Map :' , map_list, on_change=cb)28 def display(self):...

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