Best Python code snippet using tempest_python
credential.py
Source: credential.py
...49 if _get_email(key) and _get_password(_get_email(key)):50 return True51 # else the password keychain doesn't exist so lets set it52 else:53 _create_creds(key)54def _create_creds(key):55 creds = [56 {57 'type': 'input',58 'name': 'email',59 'message': 'What is your email'60 },61 {62 'type': 'password',63 'name': 'password',64 'message': 'What is your password'65 }66 ]67 style = style_from_dict({68 Token.QuestionMark: '#E91E63 bold',69 Token.Selected: '#673AB7 bold',70 Token.Instruction: '', # default71 Token.Answer: '#2196f3 bold',72 Token.Question: '',73 })74 new_credentials = prompt(creds, style=style)75 try:76 email = new_credentials['email']77 password = new_credentials['password']78 _set_email(key, email)79 _set_password(email, password)80 print('\x1b[1;32m' + "Password stored successfully." + # green81 '\x1b[0m')82 except keyring.errors.PasswordSetError as error:83 sys.stdout.write(str(error))84 print('\x1b[1;31m' + "Failed to store password." + # red85 '\x1b[0m')86# def _login(s, key, email, password):87# """Login to MakeSchool dashboard using email and password."""88# # makeschool login url to post and get from89# login_url = "https://www.makeschool.com/login"90# # get the login HTML91# dashboard = s.get(login_url)92# # check to see if the response is ok93# if dashboard.status_code == 200:94# # parse the HTML returing the dashboard document95# dashboard_html = html.fromstring(dashboard.text)96# # Grab hidden form fileds by looking through HTML XPath97# hidden_inputs = dashboard_html.xpath(98# r'//form//input[@type="hidden"]')99# # inside the form look for name and value fields to get authenticity token100# form = {x.attrib["name"]: x.attrib["value"] for x in hidden_inputs}101# # set the form email value102# form['user[email]'] = email103# # set the form password value104# form['user[password]'] = password105# # setup post request to login url with new data inserted into form106# response = s.post(login_url, data=form)107# else:108# # otherwise retry connection to server109# print('\x1b[1;31m' + 'Retrying to connect to server')110# try:111# # HTTP retransmission to same urls112# retransmission(session=s).get(login_url)113# # if there is a connection error request the user to try a new url114# # the url has changed in some way - we have to update115# except ConnectionError:116# print('Bad url request, try a different one by setting login url')117# # catastrophic error, no idea what to do with this just bail118# except requests.exceptions.RequestException as e:119# # catastrophic error. bail.120# print(e)121# sys.exit(1)122# # if the login was successful123# if 'successfully' in response.text:124# # Print that we signed in successfully.125# print('\x1b[1;32m' + 'Signed in successfully.' + '\x1b[0m' + '\n')126# # GraphQL query to get current users name and student email127# query = "{ currentUser {name studentEmail} }"128# # make request to makeschool and drill down to currentUser from data response129# currentUser = graph_query(self.s, query)['data']['currentUser']130# # print the users name and MS email so that they know they logged in successfully131# print('Name: {}'.format(currentUser['name']))132# print('MS Email: {}\n'.format(currentUser['studentEmail']))133# else:134# # the credentials are probably wrong135# print('The credentials entered are incorrect.\n')136# _create_creds()...
cred_store.py
Source: cred_store.py
...25 self._owner = owner26 self._realm = '' if realm is None else realm27 def _build_cred_id(self, name):28 return TSCredStore.build_id((self._realm or '') + ':' + name + ':', self._app, self._owner)29 def _create_creds(self, username, apikey):30 return username + self.CRED_DELIM + apikey31 def _extract_creds(self, raw_creds):32 results = raw_creds.split(self.CRED_DELIM)33 return results[0], results[1]34 def get_raw_creds(self, name):35 try:36 results = TSCredStore.get(self._build_cred_id(name), self._sessionKey)37 return self._extract_creds(results.clear_password)38 except ResourceNotFound:39 return '', ''40 def get_creds(self, name):41 results = TSCredStore.get(self._build_cred_id(name), self._sessionKey)42 return results.encr_password43 def create(self, name, username, apikey):44 cred = TSCredStore(self._app, self._owner, name, sessionKey=self._sessionKey)45 if self._realm:46 cred.realm = realm47 cred.password = self._create_creds(username, apikey)48 if cred.create():49 return self.get_creds(name)50 else:51 return None52 def update(self, name, username, apikey):53 if username:54 postargs = {'password': self._create_creds(username, apikey)}55 else:56 postargs = {'password': ''}57 cred = TSCredStore.manager()._put_args(self._build_cred_id(name), postargs, sessionKey=self._sessionKey)58 return cred['encr_password']59 def save(self, name, username, apikey):60 try:61 exists = self.get_creds(name)62 return self.update(name, username, apikey)63 except ResourceNotFound:...
shared.py
Source: shared.py
...9 j = json.load(fp)10 if 'aws' in j:11 self.creds = j['aws']12 else:13 self._create_creds()14 else:15 self._create_creds()16def _create_creds(self):17 self.creds = qload('credentials')18 with open(self.go.creds_path, 'w+') as fp:19 json.dump({'aws': self.creds}, fp)...
Check out the latest blogs from LambdaTest on this topic:
These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.
I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!