How to use fill_credentials method in tempest

Best Python code snippet using tempest_python

best_day.py

Source:best_day.py Github

copy

Full Screen

...11 _name = 'api.best.day'12 url = fields.Char(_('Url'))13 username = fields.Char(_('Username'))14 password = fields.Char(_('Password'))15 def fill_credentials(self):16 return {17 'a': self.username,18 'ip': self.password19 }20 @api.model21 def get_all_hotels(self, dest):22 url = 'http://testxml.e-tsw.com/AffiliateService/AffiliateService.svc/restful/GetHotelsComplete'23 params = self.fill_credentials()24 params['d'] = dest.best_day_id25 r = self.send_request(url, params)26 hotels_table = self.env['product.hotel']27 pp_table = self.env['product.product']28 pt_table = self.env['product.template']29 categ_table = self.env['product.category']30 categ = categ_table.search([('name', '=', 'Hotel')])31 ps = self.env['product.supplierinfo']32 rp = self.env['res.partner']33 text = self.encode(r)34 hotels = etree.fromstring(text)35 for hotel in hotels:36 name = hotel[1].text37 h = hotels_table.search([('hotel_name', '=', name)])38 if not (h and h.id):39 if name.lower() != 'disponible':40 pt = pt_table.create({41 'name': name,42 'categ_id': categ.id43 })44 pp = pp_table.search([('product_tmpl_id', '=', pt.id)])45 p = hotels_table.create({46 'hotel_name': name,47 'product_id': pp.id,48 'destination': dest.id49 })50 partner = rp.search([('name', '=', 'Best Day')])51 if partner and partner.id:52 ps.create({53 'name': partner.id,54 'product_tmpl_id': pt.id55 })56 else:57 raise except_orm('Error', _("Partner error in api implementation"))58 else:59 partner = rp.search([('name', '=', 'Best Day')])60 if partner and partner.id:61 ps_item = ps.search(62 [('name', '=', partner.id), ('product_tmpl_id', '=', h.product_id.product_tmpl_id.id)])63 if not (ps_item and ps_item.id):64 ps.create({65 'name': partner.id,66 'product_tmpl_id': h.product_id.product_tmpl_id.id67 })68 else:69 raise except_orm('Error', _("Partner error in api implementation"))70 def get_all_cars(self, dest):71 url = 'http://testxml.e-tsw.com/AffiliateService/AffiliateService.svc/restful/GetHotelsComplete'72 params = self.fill_credentials()73 params['d'] = dest.best_day_id74 r = self.send_request(url, params)75 hotels = self.env['product.hotel']76 ps = self.env['product.supplierinfo']77 rp = self.env['res.partner']78 text = self.encode(r)79 hotels = etree.fromstring(text)80 for hotel in hotels:81 name = hotel[1].text82 h = hotels.search(['hotel_name', '=', name])83 if not (h and h.id):84 hotels.create({85 'hotel_name': name86 })87 partner = rp.search('name', '=', 'Best Day')88 if partner and partner.id:89 p = hotels.search(['hotel_name', '=', name])90 ps.create({91 'name': partner.id,92 'product_tmpl_id': p.product_id.product_tmpl_id.id93 })94 else:95 raise except_orm('Error', _("Partner error in api implementation"))96 return self.get_products('hotel')97 @api.model98 def get_products(self, _type, destination, api='openerp'):99 prod = self.env['product.product']100 prod_type_table = self.env['product.' + _type]101 categ_table = self.env['product.category']102 categ = categ_table.search([('name', '=', str(_type).capitalize())])103 ps = self.env['product.supplierinfo']104 rp = self.env['res.partner']105 partner = rp.search([('name', '=', 'Best Day')])106 prods = [x.product_tmpl_id.id for x in ps.search([('name', '=', partner.id)])]107 ids = [x.product_id.id for x in prod_type_table.search([('destination', '=', destination)])]108 prods = prod.search(109 [('product_tmpl_id.id', 'in', prods), ('product_tmpl_id.categ_id', '=', categ.id)])110 if api == 'openerp':111 return [y.id for y in prods if y.id in ids]112 return [x for x in prods if x.id in ids]113 def hotels_request(self, params):114 url = 'http://testxml.e-tsw.com/AffiliateService/AffiliateService.svc/restful/GetHotels'115 p = self.fill_credentials()116 p['c'] = ''117 p['sd'] = ''118 p['ed'] = ''119 p['h'] = ''120 p['rt'] = ''121 p['mp'] = ''122 p['r'] = ''123 p['d'] = ''124 p['l'] = ''125 p['hash'] = ''126 r = self.send_request(url, _dict=p)127 text = self.encode(r)128 def send_request(self, url, _dict):129 return requests.get(url, params=_dict)130 def encode(self, r):131 return r.text.encode('utf-8')132 def parse_countries(self, r, destinations):133 tree = etree.fromstring(self.encode(r))134 codes = []135 for x in tree:136 tmp = destinations.search([('name', '=', x[1].text)])137 if x[0].tag.lower() == 'id' and x[1].tag.lower() == 'name':138 if tmp and tmp.id:139 tmp.write({140 'name': x[1].text,141 'best_day_id': x[0].text142 })143 else:144 destinations.create({145 'name': x[1].text,146 'best_day_id': x[0].text147 })148 codes.append(x[0].text)149 return codes150 def parse_cities(self, r, destinations, code):151 tree = etree.fromstring(self.encode(r))152 parent = destinations.search([('best_day_id', '=', code)])153 if not (parent and parent.id):154 return155 for x in tree:156 if not x[0].text == '101':157 tmp = destinations.search([('name', '=', x[1].text)])158 if x[0].tag.lower() == 'id' and x[1].tag.lower() == 'name':159 if tmp and tmp.id:160 tmp.write({161 'name': x[1].text,162 'best_day_id': x[0].text,163 'parent_id': parent.id164 })165 else:166 destinations.create({167 'name': x[1].text,168 'best_day_id': x[0].text,169 'parent_id': parent.id170 })171 @api.model172 def get_destinations(self, name):173 params = self.fill_credentials()174 destinations = self.env['destination']175 code = name.best_day_id176 dsts = destinations.search([('best_day_id', '!=', False), ('parent_id', '=', name.id)])177 destin_url = 'http://testxml.e-tsw.com/AffiliateService/AffiliateService.svc/restful/GetDestinations'178 if len(dsts):179 return dsts180 else:181 params['ic'] = code182 r = requests.get(destin_url, params=params)183 self.parse_cities(r, destinations, code)184 dsts = destinations.search([('best_day_id', '!=', False), ('parent_id', '=', name.id)])185 return dsts186 def get_countries(self):187 country_url = 'http://testxml.e-tsw.com/AffiliateService/AffiliateService.svc/restful/GetCountries'188 params = self.fill_credentials()189 destinations = self.env['destination']190 r = requests.get(country_url, params=self.fill_credentials())...

Full Screen

Full Screen

test_classes.py

Source:test_classes.py Github

copy

Full Screen

...22 def test_wrong_email_login(self):23 self.website_login('aslkjdflka', 'password1111')24class Reddit(TestWebsite):25 URL = 'https://www.reddit.com/'26 def fill_credentials(self, username, password):27 self.driver.get(self.URL)28 login_button_1 = self.driver.find_element_by_class_name('_3Wg53T10KuuPmyWOMWsY2F')29 login_button_1.click()30 self.driver.switch_to.frame(self.driver.find_element_by_class_name('_25r3t_lrPF3M6zD2YkWvZU'))31 self.driver.implicitly_wait(1000)32 username_input = self.driver.find_element_by_id('loginUsername')33 password_input = self.driver.find_element_by_id('loginPassword')34 username_input.send_keys(username)35 password_input.send_keys(password)36 def incorrect_username_or_password_showed(self, email, password):37 self.fill_credentials(email, password)38 login_button = self.driver.find_element_by_class_name('AnimatedForm__submitButton')39 login_button.click()40 desired_error_message = 'Incorrect username or password'41 error_showed_up = WebDriverWait(self.driver, 5).until(EC.text_to_be_present_in_element(42 (By.CLASS_NAME, 'AnimatedForm__errorMessage'),43 desired_error_message44 ))45 return error_showed_up46 def test_wrong_username(self):47 print(self.incorrect_username_or_password_showed('asdlkfjwerzxc', 'password'))48 def test_wrong_password(self):49 print(self.incorrect_username_or_password_showed('john', 'password'))50 def test_too_long_username(self):51 self.fill_credentials('012345678901234567890123456789', 'password')52 desired_error_message = 'Username must be between 3 and 20 characters'53 error_showed_up = WebDriverWait(self.driver, 5).until(EC.text_to_be_present_in_element(54 (By.CLASS_NAME, 'AnimatedForm__errorMessage'),55 desired_error_message56 ))...

Full Screen

Full Screen

mindbody.py

Source:mindbody.py Github

copy

Full Screen

...8 if service_name not in _CLIENTS:9 url = "https://api.mindbodyonline.com/0_5/" + service_name + "Service.asmx?wsdl"10 _CLIENTS[service_name] = suds.client.Client(url)11 return _CLIENTS[service_name]12def fill_credentials(client, request, site_ids):13 source_creds = client.factory.create('SourceCredentials')14 source_creds.SourceName = SOURCE_NAME15 source_creds.Password = SOURCE_PASSWORD16 source_creds.SiteIDs.int = site_ids17 request.XMLDetail = 'Full'18 request.SourceCredentials = source_creds19def get_request(client, request_name, site_id):20 request = client.factory.create(request_name)21 if hasattr(request, 'Request'):22 request = request.Request23 fill_credentials(client, request, [site_id])24 return request25def get_activation_link(site_id):26 client = get_client("Site")27 request = get_request(client, "GetActivationCode", site_id)28 result = client.service.GetActivationCode(request)29 return result.ActivationLink30def get_classes(start_time, end_time, hide_canceled_classes, site_id):31 service = get_client("Class")32 request = get_request(service, "GetClasses", site_id)33 request.StartDateTime = start_time34 request.EndDateTime = end_time35 request.HideCanceledClasses = hide_canceled_classes36 # This improves speed from 3 seconds to 2 seconds, so the additional debugging advantages outweigh the speed benefits37 #request.XMLDetail = 'Bare'...

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