How to use waiter method in elementium

Best Python code snippet using elementium_python

waiter.py

Source:waiter.py Github

copy

Full Screen

...30 :param client: The botocore client associated with the service.31 :rtype: botocore.waiter.Waiter32 :return: The waiter object.33 """34 single_waiter_config = waiter_model.get_waiter(waiter_name)35 operation_name = xform_name(single_waiter_config.operation)36 operation_method = NormalizedOperationMethod(37 getattr(client, operation_name))38 # Create a new wait method that will serve as a proxy to the underlying39 # Waiter.wait method. This is needed to attach a docstring to the40 # method.41 def wait(self, **kwargs):42 Waiter.wait(self, **kwargs)43 wait.__doc__ = WaiterDocstring(44 waiter_name=waiter_name,45 event_emitter=client.meta.events,46 service_model=client.meta.service_model,47 service_waiter_model=waiter_model,48 include_signature=False49 )50 # Rename the waiter class based on the type of waiter.51 waiter_class_name = str('%s.Waiter.%s' % (52 get_service_module_name(client.meta.service_model),53 waiter_name))54 # Create the new waiter class55 documented_waiter_cls = type(56 waiter_class_name, (Waiter,), {'wait': wait})57 # Return an instance of the new waiter class.58 return documented_waiter_cls(59 waiter_name, single_waiter_config, operation_method60 )61class NormalizedOperationMethod(object):62 def __init__(self, client_method):63 self._client_method = client_method64 def __call__(self, **kwargs):65 try:66 return self._client_method(**kwargs)67 except ClientError as e:68 return e.response69class WaiterModel(object):70 SUPPORTED_VERSION = 271 def __init__(self, waiter_config):72 """73 Note that the WaiterModel takes ownership of the waiter_config.74 It may or may not mutate the waiter_config. If this is a concern,75 it is best to make a copy of the waiter config before passing it to76 the WaiterModel.77 :type waiter_config: dict78 :param waiter_config: The loaded waiter config79 from the <service>*.waiters.json file. This can be80 obtained from a botocore Loader object as well.81 """82 self._waiter_config = waiter_config['waiters']83 # These are part of the public API. Changing these84 # will result in having to update the consuming code,85 # so don't change unless you really need to.86 version = waiter_config.get('version', 'unknown')87 self._verify_supported_version(version)88 self.version = version89 self.waiter_names = list(sorted(waiter_config['waiters'].keys()))90 def _verify_supported_version(self, version):91 if version != self.SUPPORTED_VERSION:92 raise WaiterConfigError(93 error_msg=("Unsupported waiter version, supported version "94 "must be: %s, but version of waiter config "95 "is: %s" % (self.SUPPORTED_VERSION,96 version)))97 def get_waiter(self, waiter_name):98 try:99 single_waiter_config = self._waiter_config[waiter_name]100 except KeyError:101 raise ValueError("Waiter does not exist: %s" % waiter_name)102 return SingleWaiterConfig(single_waiter_config)103class SingleWaiterConfig(object):104 """Represents the waiter configuration for a single waiter.105 A single waiter is considered the configuration for a single106 value associated with a named waiter (i.e TableExists).107 """108 def __init__(self, single_waiter_config):109 self._config = single_waiter_config110 # These attributes are part of the public API.111 self.description = single_waiter_config.get('description', '')...

Full Screen

Full Screen

waiter-queue.methods.ts

Source:waiter-queue.methods.ts Github

copy

Full Screen

1import { Meteor } from 'meteor/meteor';2import { Job, JobCollection } from 'meteor/vsivsi:job-collection';3import { UserDetail } from '../../../models/auth/user-detail.model';4import { UserDetails } from '../../../collections/auth/user-detail.collection';5import { WaiterCallDetail } from '../../../models/restaurant/waiter-call-detail.model';6import { WaiterCallDetails } from '../../../collections/restaurant/waiter-call-detail.collection';7import { Restaurant, RestaurantTurn } from '../../../models/restaurant/restaurant.model';8import { Restaurants, RestaurantTurns } from '../../../collections/restaurant/restaurant.collection';9import { Accounts } from '../../../collections/restaurant/account.collection';10import { Orders } from '../../../collections/restaurant/order.collection';11import { Tables } from '../../../collections/restaurant/table.collection';12if (Meteor.isServer) {13 Meteor.methods({14 /**15 * This Meteor Method add a job in the Waiter call queue16 * @param {boolean} _priorityHigh17 * @param {any} _data18 */19 waiterCall: function (_queue: string, _priorityHigh: boolean, _data: any) {20 let priority: string = 'normal';21 let delay: number = 0;22 var waiterCallDetail: string;23 var job = new Job(24 _queue,25 'waiterCall',26 { data: '' }27 );28 job.priority(priority)29 .delay(delay)30 .save();31 if (_priorityHigh) {32 priority = 'critical', delay = 10000;33 WaiterCallDetails.update({ job_id: _data.job_id }, { $set: { waiter_id: _data.waiter_id, job_id: job._doc._id } });34 waiterCallDetail = _data.waiter_call_id;35 } else {36 let newTurn = Meteor.call('turnCreate', _data);37 waiterCallDetail = WaiterCallDetails.collection.insert({38 restaurant_id: _data.restaurants,39 table_id: _data.tables,40 user_id: _data.user,41 turn: newTurn,42 status: _data.status,43 creation_user: _data.user,44 creation_date: new Date(),45 queue: _queue,46 job_id: job._doc._id,47 type: _data.type,48 order_id: _data.order_id,49 });50 }51 return;52 },53 processJobs: function (job, callback, queueName, data) {54 let data_detail: WaiterCallDetail;55 let usr_id_enabled: UserDetail;56 data_detail = WaiterCallDetails.findOne({ job_id: job._doc._id });57 if (data_detail === undefined && data_detail === null) {58 Meteor.call('waiterCall', queueName, true, data);59 data_detail = WaiterCallDetails.findOne({ job_id: job._doc._id });60 }61 let restaurant = Restaurants.findOne({ _id: data_detail.restaurant_id });62 usr_id_enabled = Meteor.call('validateWaiterEnabled', data_detail.restaurant_id, restaurant.max_jobs, data_detail.table_id);63 if (!usr_id_enabled) {64 Meteor.call('jobRemove', queueName, job._doc._id, data_detail);65 usr_id_enabled = Meteor.call('validateWaiterEnabled', data_detail.restaurant_id, restaurant.max_jobs, data_detail.table_id);66 }67 Job.getJob(queueName, job._doc._id, function (err, job) {68 if (job) {69 job.done(function (err, result) { });70 //Storage of turns the restaurants by date71 var toDate = new Date().toLocaleDateString();72 RestaurantTurns.update({ restaurant_id: data_detail.restaurant_id, creation_date: { $gte: new Date(toDate) } },73 {74 $set: { last_waiter_id: usr_id_enabled.user_id, modification_user: 'SYSTEM', modification_date: new Date(), }75 });76 //Waiter call detail update in completed state77 WaiterCallDetails.update({ job_id: job._doc._id },78 {79 $set: { "waiter_id": usr_id_enabled.user_id, "status": "completed" }80 });81 //Waiter update of current jobs and state82 let usr_jobs: number = usr_id_enabled.jobs + 1;83 if (usr_jobs < restaurant.max_jobs) {84 UserDetails.update({ user_id: usr_id_enabled.user_id }, { $set: { "jobs": usr_jobs } });85 } else if (usr_jobs == restaurant.max_jobs) {86 UserDetails.update({ user_id: usr_id_enabled.user_id }, { $set: { "enabled": false, "jobs": usr_jobs } });87 }88 }89 });90 callback();91 },92 /**93 * Job remove94 * @param pQueueName 95 * @param pJobId 96 * @param pDataDetail 97 * @param pEnabled 98 */99 jobRemove(pQueueName, pJobId, pDataDetail) {100 Job.getJob(pQueueName, pJobId, function (err, job) {101 if (job) {102 job.cancel();103 job.remove(function (err, result) {104 if (result) {105 if (pDataDetail !== null && pDataDetail !== undefined) {106 var data: any = {107 job_id: job._doc._id,108 restaurants: pDataDetail.restaurant_id,109 tables: pDataDetail.table_id,110 user: pDataDetail.user_id,111 waiter_id: pDataDetail.waiter_id,112 status: 'waiting'113 };114 Meteor.call('waiterCall', pQueueName, true, data);115 }116 }117 });118 }119 });120 },121 /**122 * This Meteor method allow get new turn to the client123 * @param { any } _data 124 */125 turnCreate(_data: any): number {126 var newTurn: number = 1;127 var toDate = new Date().toLocaleDateString();128 var restaurantTurn: RestaurantTurn = RestaurantTurns.findOne({129 restaurant_id: _data.restaurants,130 creation_date: { $gte: new Date(toDate) }131 });132 if (restaurantTurn) {133 newTurn = restaurantTurn.turn + 1;134 RestaurantTurns.update(135 { _id: restaurantTurn._id },136 {137 $set: { turn: newTurn, modification_user: 'SYSTEM', modification_date: new Date(), }138 });139 } else {140 RestaurantTurns.insert({141 restaurant_id: _data.restaurants,142 turn: newTurn,143 last_waiter_id: "",144 creation_user: 'SYSTEM',145 creation_date: new Date(),146 });147 }148 return newTurn;149 },150 /**151 * This Meteor Method allow delete a job in the Waiter call queue152 * @param {string} _waiter_call_detail_id153 * @param {string} _waiter_id154 */155 closeCall: function (_jobDetail: WaiterCallDetail, _waiter_id: string) {156 Job.getJob(_jobDetail.queue, _jobDetail.job_id, function (err, job) {157 job.remove(function (err, result) {158 WaiterCallDetails.update({ _id: _jobDetail._id },159 {160 $set: { "status": "closed", modification_user: _waiter_id, modification_date: new Date() }161 });162 let waiterDetail = WaiterCallDetails.findOne({ job_id: _jobDetail.job_id });163 if (waiterDetail.type === "SEND_ORDER" && waiterDetail.order_id !== null) {164 Orders.update({ _id: waiterDetail.order_id },165 {166 $set: {167 status: 'ORDER_STATUS.DELIVERED',168 modification_user: _waiter_id,169 modification_date: new Date()170 }171 }172 );173 let order = Orders.findOne({ _id: waiterDetail.order_id });174 if (order) {175 let account = Accounts.findOne({ _id: order.accountId });176 Accounts.update({ _id: account._id }, { $set: { total_payment: (account.total_payment + order.totalPayment) } });177 }178 }179 let usr_detail: UserDetail = UserDetails.findOne({ user_id: _waiter_id });180 if (usr_detail) {181 let jobs = usr_detail.jobs - 1;182 UserDetails.update({ _id: usr_detail._id }, { $set: { "enabled": true, "jobs": jobs } });183 }184 });185 });186 return;187 },188 closeWaiterCall: function (_jobDetail: WaiterCallDetail) {189 Job.getJob(_jobDetail.queue, _jobDetail.job_id, function (err, job) {190 job.remove(function (err, result) {191 WaiterCallDetails.update({ _id: _jobDetail._id },192 {193 $set: { "status": "closed", modification_user: _jobDetail.waiter_id, modification_date: new Date() }194 });195 let usr_detail: UserDetail = UserDetails.findOne({ user_id: _jobDetail.waiter_id });196 if (usr_detail) {197 let jobs = usr_detail.jobs - 1;198 UserDetails.update({ _id: usr_detail._id }, { $set: { "enabled": true, "jobs": jobs } });199 }200 });201 });202 return;203 },204 /**205 * This meteor method allow cancel call to waiter by the user206 * @param {WaiterCallDetail} _jobDetail207 * @param {string} _userId208 */209 cancelCallClient: function (_jobDetail: WaiterCallDetail, _userId: string) {210 Job.getJob(_jobDetail.queue, _jobDetail.job_id, function (err, job) {211 if (job._doc.status !== 'completed') {212 job.cancel();213 }214 job.remove(function (err, result) {215 WaiterCallDetails.update({ job_id: _jobDetail.job_id },216 {217 $set: { "status": "cancel", modification_user: _userId, modification_date: new Date() }218 });219 let waiterDetail = WaiterCallDetails.findOne({ job_id: _jobDetail.job_id });220 if (waiterDetail.type === "CALL_OF_CUSTOMER" && waiterDetail.waiter_id) {221 let usr_detail = UserDetails.findOne({ user_id: waiterDetail.waiter_id });222 if (usr_detail) {223 let jobs = usr_detail.jobs - 1;224 UserDetails.update({ user_id: waiterDetail.waiter_id }, { $set: { "enabled": true, "jobs": jobs } });225 }226 }227 });228 });229 },230 /**231 * This function validate waiters enabled232 * @param {string} _restaurant233 * @param {string} _maxJobs234 */235 validateWaiterEnabled(_restaurant: string, _maxJobs: string, _tableId: string): UserDetail {236 let usr: UserDetail = null;237 let position: number = 0;238 let _randomLast: string;239 let table = Tables.findOne({ _id: _tableId });240 let waiterEnableds = UserDetails.collection.find({241 restaurant_work: _restaurant,242 is_active: true,243 enabled: true,244 role_id: "200",245 jobs: { $lt: _maxJobs },246 table_assignment_init: { $lte: table._number },247 table_assignment_end: { $gte: table._number }248 });249 var count = waiterEnableds.count();250 if (count > 0) {251 let restaurantTurn = RestaurantTurns.findOne({ "restaurant_id": _restaurant },252 {253 sort: { "creation_date": -1 }254 }255 );256 if (restaurantTurn) {257 _randomLast = restaurantTurn.last_waiter_id;258 }259 do {260 position = Meteor.call('getRandomInt', 0, count - 1);261 usr = waiterEnableds.fetch()[position];262 }263 while (usr.user_id == _randomLast && count > 1);264 return usr;265 } else {266 return null;267 }268 },269 /**270 * This function return a random number271 * @param {string} _restaurant272 */273 getRandomInt(min, max): number {274 return Math.floor(Math.random() * (max - min + 1)) + min;275 }276 });...

Full Screen

Full Screen

_autoWaiter-dbg.js

Source:_autoWaiter-dbg.js Github

copy

Full Screen

1/*!2 * OpenUI53 * (c) Copyright 2009-2022 SAP SE or an SAP affiliate company.4 * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.5 */6sap.ui.define([7 "sap/ui/thirdparty/jquery",8 "sap/ui/base/Object",9 "sap/ui/test/_OpaLogger",10 "sap/ui/test/autowaiter/_XHRWaiter",11 "sap/ui/test/autowaiter/_timeoutWaiter",12 "sap/ui/test/autowaiter/_promiseWaiter",13 "sap/ui/test/autowaiter/_navigationContainerWaiter",14 "sap/ui/test/autowaiter/_UIUpdatesWaiter",15 "sap/ui/test/autowaiter/_moduleWaiter",16 "sap/ui/test/autowaiter/_resourceWaiter"17], function(18 jQueryDOM,19 UI5Object,20 _OpaLogger,21 _XHRWaiter,22 _timeoutWaiter,23 _promiseWaiter,24 _navigationContainerWaiter,25 _UIUpdatesWaiter,26 _moduleWaiter,27 _resourceWaiter28) {29 "use strict";30 var aWaiters = [];31 var oLogger = _OpaLogger.getLogger("sap.ui.test.autowaiter._autoWaiter");32 var AutoWaiter = UI5Object.extend("sap.ui.test.autowaiter._autoWaiter", {33 registerWaiter: function (sName, vWaiter) {34 return new Promise(function (fnResolve, fnReject) {35 if (typeof vWaiter === "string") {36 sap.ui.require([vWaiter], this._addWaiter(sName, fnResolve, fnReject), function (error) {37 fnReject("Failed to load waiter " + sName + ": " + error);38 });39 } else if (typeof vWaiter === "object") {40 this._addWaiter(sName, fnResolve, fnReject)(vWaiter);41 }42 }.bind(this));43 },44 hasToWait: function () {45 var result = false;46 // execute wait helpers in sequence and stop on the first that returns true47 // eg: there's no use to call _timeoutWaiter if _UIUpdatesWaiter is true48 aWaiters.forEach(function (mWaiter) {49 if (!result && mWaiter.waiter.isEnabled() && mWaiter.waiter.hasPending()) {50 result = true;51 }52 });53 if (!result) {54 oLogger.timestamp("opa.autoWaiter.syncPoint");55 oLogger.debug("AutoWaiter syncpoint");56 }57 return result;58 },59 extendConfig: function (oConfig) {60 if (!jQueryDOM.isEmptyObject(oConfig)) {61 aWaiters.forEach(function (mWaiter) {62 if (mWaiter.waiter.extendConfig) {63 mWaiter.waiter.extendConfig(oConfig[mWaiter.name]);64 }65 });66 }67 },68 getWaiters: function () {69 return aWaiters.slice();70 },71 _addWaiter: function (sName, fnSuccess, fnError) {72 fnSuccess = fnSuccess || function () {};73 fnError = fnError || function () {};74 return function (oWaiter) {75 if (typeof oWaiter.hasPending !== "function") {76 fnError("Waiter " + sName + " should have a hasPending method");77 } else if (typeof oWaiter.isEnabled !== "function") {78 fnError("Waiter " + sName + " should have an isEnabled method");79 } else {80 var bExists;81 aWaiters.forEach(function (mWaiter) {82 if (mWaiter.name === sName) {83 oLogger.debug("Waiter with name " + sName + " will be overridden!");84 bExists = true;85 mWaiter.waiter = oWaiter;86 }87 });88 if (!bExists) {89 aWaiters.push({90 name: sName,91 waiter: oWaiter92 });93 }94 fnSuccess(oWaiter);95 }96 };97 }98 });99 var oAutoWaiter = new AutoWaiter();100 var mDefaultWaiters = {101 xhrWaiter: _XHRWaiter,102 timeoutWaiter: _timeoutWaiter,103 promiseWaiter: _promiseWaiter,104 navigationWaiter: _navigationContainerWaiter,105 uiUpdatesWaiter: _UIUpdatesWaiter,106 moduleWaiter: _moduleWaiter,107 resourceWaiter: _resourceWaiter108 };109 Object.keys(mDefaultWaiters).forEach(function (sWaiter) {110 return oAutoWaiter._addWaiter(sWaiter)(mDefaultWaiters[sWaiter]);111 });112 return oAutoWaiter;...

Full Screen

Full Screen

Waiter.controller.ts

Source:Waiter.controller.ts Github

copy

Full Screen

...11 12 @Security('api_key')13 @Tags('Admin')14 @Post("/getwaiter")15 async getwaiter(@Body() getreq:GetReqWaiter 16 ): Promise<SaveUpdateResWaiter>{17 console.log(getreq)18 const waiter:any = await new MainWaiter().getWaiter(<any>getreq);19 20 if(waiter === null) throw new CustomeError(404 , "Waiter Not Found")21 return <SaveUpdateResWaiter>waiter;22 }23 @Security('api_key')24 @Tags('Admin')25 @Get('/getallwaiter')26 @Response(400, 'heello')27 async getallWaiter(): Promise<SaveUpdateResWaiter[]>{28 29 const waiter: any = await new MainWaiter().getallwaiter().populate("order")30 return <SaveUpdateResWaiter[]> waiter31 }32 @Security('api_key')33 @Tags('Admin')34 @Post("/savewaiter")35 async savewaiter(@Body() savereq:SaveReqWaiter): Promise<SaveUpdateResWaiter>{36 const newwaiter:any = await new MainWaiter().saveWaiter(<any> savereq)37 return <SaveUpdateResWaiter> newwaiter;38 }39 @Security('api_key')40 @Tags('Admin')41 @Put("/updatewaiter")42 43 44 async updatewaiter( @Body() updatereq:UpdateReqWaiter ) : Promise<SaveUpdateResWaiter>{45 console.log(updatereq)46 const updatewaiter:any= await new MainWaiter().updateWaiter(<any> updatereq)47 if(updatewaiter === null) throw new CustomeError(404, 'not supported method')48 return <SaveUpdateResWaiter>updatewaiter;49 }50 51 @Security('api_key')52 @Tags('Admin')53 @Delete("/deletewaiter")54 @SuccessResponse("200","Product Deleted")55 async deletewaiter(@Body() deletereq:DelReqWaiter):Promise<any>{56 return await new MainWaiter().delWaiter(<any> deletereq)57 }58 59 @Tags('Waiter')60 @Post("/loginwaiter")61 async login(@Body() data:LoginWaiter):Promise<SaveUpdateResWaiter>{62 console.log(data)63 const logwaiter:any = await new MainWaiter().loginWaiter(data.email)64 if(logwaiter === null) throw new CustomeError(404 , "Wrong email and password ")65 return logwaiter;66 }67 @Security('jwt')68 @Tags('Waiter')69 @Get('/waiterorder')...

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