Best Python code snippet using tempest_python
test_configured_creds.py
Source: test_configured_creds.py
...52 if filled:53 self.assertIsNotNone(getattr(credentials, attr))54 else:55 self.assertIsNone(getattr(credentials, attr))56 def _verify_credentials(self, credentials_class, filled=True,57 identity_version=None):58 for ctype in common_creds.CREDENTIAL_TYPES:59 if identity_version is None:60 creds = common_creds.get_configured_credentials(61 credential_type=ctype, fill_in=filled)62 else:63 creds = common_creds.get_configured_credentials(64 credential_type=ctype, fill_in=filled,65 identity_version=identity_version)66 self._check(creds, credentials_class, filled)67 def test_create(self):68 creds = self._get_credentials()69 self.assertEqual(self.attributes, creds._initial)70 def test_create_invalid_attr(self):71 self.assertRaises(lib_exc.InvalidCredentials,72 self._get_credentials,73 attributes=dict(invalid='fake'))74 def test_get_configured_credentials(self):75 self.useFixture(fixtures.LockFixture('auth_version'))76 self._verify_credentials(credentials_class=self.credentials_class)77 def test_get_configured_credentials_unfilled(self):78 self.useFixture(fixtures.LockFixture('auth_version'))79 self._verify_credentials(credentials_class=self.credentials_class,80 filled=False)81 def test_get_configured_credentials_version(self):82 # version specified and not loaded from config83 self.useFixture(fixtures.LockFixture('auth_version'))84 self._verify_credentials(credentials_class=self.credentials_class,85 identity_version=self.identity_version)86 def test_is_valid(self):87 creds = self._get_credentials()88 self.assertTrue(creds.is_valid())89class ConfiguredV3CredentialsTests(ConfiguredV2CredentialsTests):90 attributes = {91 'username': 'fake_username',92 'password': 'fake_password',93 'project_name': 'fake_project_name',94 'user_domain_name': 'fake_domain_name'95 }96 credentials_class = auth.KeystoneV3Credentials97 identity_response = fake_identity._fake_v3_response98 tokenclient_class = v3_client.V3TokenClient...
test_cred_provider.py
Source: test_cred_provider.py
...52 if filled:53 self.assertIsNotNone(getattr(credentials, attr))54 else:55 self.assertIsNone(getattr(credentials, attr))56 def _verify_credentials(self, credentials_class, filled=True,57 identity_version=None):58 for ctype in cred_provider.CREDENTIAL_TYPES:59 if identity_version is None:60 creds = cred_provider.get_configured_credentials(61 credential_type=ctype, fill_in=filled)62 else:63 creds = cred_provider.get_configured_credentials(64 credential_type=ctype, fill_in=filled,65 identity_version=identity_version)66 self._check(creds, credentials_class, filled)67 def test_create(self):68 creds = self._get_credentials()69 self.assertEqual(self.attributes, creds._initial)70 def test_create_invalid_attr(self):71 self.assertRaises(lib_exc.InvalidCredentials,72 self._get_credentials,73 attributes=dict(invalid='fake'))74 def test_get_configured_credentials(self):75 self.useFixture(fixtures.LockFixture('auth_version'))76 self._verify_credentials(credentials_class=self.credentials_class)77 def test_get_configured_credentials_unfilled(self):78 self.useFixture(fixtures.LockFixture('auth_version'))79 self._verify_credentials(credentials_class=self.credentials_class,80 filled=False)81 def test_get_configured_credentials_version(self):82 # version specified and not loaded from config83 self.useFixture(fixtures.LockFixture('auth_version'))84 self._verify_credentials(credentials_class=self.credentials_class,85 identity_version=self.identity_version)86 def test_is_valid(self):87 creds = self._get_credentials()88 self.assertTrue(creds.is_valid())89class ConfiguredV3CredentialsTests(ConfiguredV2CredentialsTests):90 attributes = {91 'username': 'fake_username',92 'password': 'fake_password',93 'project_name': 'fake_project_name',94 'user_domain_name': 'fake_domain_name'95 }96 credentials_class = auth.KeystoneV3Credentials97 identity_response = fake_identity._fake_v3_response98 tokenclient_class = v3_client.V3TokenClientJSON...
main.py
Source: main.py
...4from bottle import *5from commons import *6import datetime7#å
é¨8def _verify_credentials():9 auth = request.get_cookie("jiepangauth", secret='jiepangx@pp')10 if auth:11 user = call_api('v1/account/verify_credentials',{},auth)12 if 'error' in user:13 response.set_cookie("jiepangauth", "", secret='jiepangx@pp',expires=datetime.datetime.utcnow())14 else:15 return user16 return False17#éææ件18from bottle import static_file19@route('/static/:path#.+#')20def server_static(path):21 return static_file(path, root='./static')22#ç½é¡µ23@route('/')24@get('/index')25def index_form():26 if _verify_credentials():27 redirect('/home')28 return mako_template('index')29@post('/index')30def index_login():31 username = request.forms.get('username')32 password = request.forms.get('password')33 auth = base64.encodestring('%s:%s' % (username,password))34 user = call_api('v1/account/verify_credentials',{},auth)35 if 'error' in user and user['error'] == 401:36 abort(401, u'Username/Password Error')37 response.set_cookie("jiepangauth", auth, secret='jiepangx@pp')38 redirect("/home?words=1")39@route('/home')40def home():41 userdata = _verify_credentials()42 if not userdata:43 redirect('/')44 user = User(userdata,request.get_cookie("jiepangauth", secret='jiepangx@pp'))45 rlt = []46 words = [item['w'] for item in db.words.find({'u': userdata['id'],'status':1})]47 for feed in user.feeds:48 feed['header'] = types[feed['type']] % (feed['user']['nick'],'location' in feed and feed['location']['name'] or '')49 if request.GET.get('words'):50 toadd = False51 for word in words:52 if word in feed['body']:53 feed['body'] = feed['body'].replace(word,'<span style="color:%s">%s</span>' % (random.choice(colors),word))54 toadd = True55 if toadd:56 rlt.append(feed)57 else:58 rlt.append(feed)59 return mako_template('home', nick=user.nick, feeds=rlt)60@route('/voice')61def voice():62 import urllib63 response.content_type = 'audio/mpeg'64 response.body = get_voice()65 #response.body = 'http://translate.google.com/translate_tts?ie=UTF-8&q=%E4%BD%A0%E4%BB%96%E5%A6%88%E7%9A%84&tl=zh-CN'66 return67@route('/logout')68def logout():69 response.set_cookie("jiepangauth", "", secret='jiepangx@pp',expires=datetime.datetime.utcnow())70 redirect('/')71@route('/settings')72def settings():73 userdata = _verify_credentials()74 if not userdata:75 redirect('/')76 words = []77 cursor = db.words.find({'u': userdata['id']})78 for item in cursor:79 print item80 words.append({'word': item['w'], 'status': item['status'], 'created_on': datetime.datetime.strftime(item['c'] + datetime.timedelta(hours=8),'%m/%d %H:%M:%S'), 'id': item['_id']})81 #left panel - æåå¨å82 #right panel - æåä¸ä¸ªï¼æåå¨åã83 # right = words[-3:]84 # right.reverse()85 return mako_template('settings',left=words)86@route('/settings/add/:word')87def add_word(word):88 word = word.strip()89 userdata = _verify_credentials()90 if not userdata:91 redirect('/')92 if db.words.find_one({'w': word,'u': userdata['id']}):93 return 'false'94 now = datetime.datetime.utcnow()95 db.words.insert({'w': word,'u': userdata['id'],'c': now,'status':1})96 nowstr = datetime.datetime.strftime(now + datetime.timedelta(hours=8),'%m/%d %H:%M:%S')97 return json_encode({'w': word, 'c': nowstr})98@route('/settings/delete/:word')99def delete_word(word):100 word = word.strip()101 userdata = _verify_credentials()102 if not userdata:103 redirect('/')104 if not db.words.find_one({'w': word,'u': userdata['id']}):105 return 'false'106 db.words.remove({'w': word,'u': userdata['id']})107 return 'true'108@route('/settings/update/:word/:status')109def update_word(word,status):110 word = word.strip()111 status = int(status)112 if status != 0:113 status = 1114 print word,status115 userdata = _verify_credentials()116 if not userdata:117 redirect('/')118 if not db.words.find_one({'w': word,'u': userdata['id']}):119 return 'false'120 db.words.update({'w': word,'u': userdata['id']},{'$set':{'status':status}})121 return 'true'122@error(404)123def error404(error):...
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!!