Best Python code snippet using tempest_python
test_sys_admin_delete.py
Source:test_sys_admin_delete.py
1from api.api_get_data import getter2import pytest3import allure4@pytest.mark.usefixtures('add_user')5@pytest.mark.usefixtures('add_test_role')6@pytest.mark.usefixtures("add_dictionaries_company")7class TestSysAdminDeleteFail(object):8 """9 ä¸è½å é¤çæ
åµ10 åæ°å表11 "id": "string",12 "token": "string",13 "userid": "string"14 """15 @pytest.mark.parametrize(('login_phone', 'login_password', 'update_user_phone',16 'update_user_password', 'except_message', 'except_status'),17 getter.load_yaml('SystemManagementData.yml')['test_sys_admin_delete']['test_sys_admin_delete_fail'])18 def test_delete_fail(self, login_phone, login_password, update_user_phone, update_user_password,19 except_message, except_status):20 with allure.step("step1: æ¥éª¤1 ==>> ç»å½å¹¶è·åtoken,userid,cookies"):21 token, userId, cookies = getter.get_login_token_cookies(login_phone, login_password, True)22 with allure.step("step2: æ¥éª¤2 ==>> ç»å½è¢«å é¤ç¨æ·ï¼è·å该ç¨æ·id,ç¹æ®æ
åµå¤æï¼èªå·±å é¤èªå·±è´¦å·"):23 if login_phone == update_user_phone:24 update_user_id = userId25 else:26 update_user_id = getter.user_login(phone=update_user_phone, password=update_user_password,27 rememberMe=False).json()['data']['sysAdmin']['id']28 with allure.step("step3: æ¥éª¤3 ==>> å é¤å
¶ä»ç¨æ·"):29 rsp_delete = getter.user_delete(cookies, id=update_user_id, token=token, userid=userId)30 print(rsp_delete.json())31 assert rsp_delete.status_code == 20032 assert rsp_delete.json()['data'] is None33 assert rsp_delete.json()['message'] == except_message34 assert rsp_delete.json()['status'] == except_status35@pytest.mark.usefixtures('add_user')36class TestSysAdminDeleteSuccess(object):37 """38 å¯ä»¥æåå é¤çæ
åµ39 åæ°å表S40 "id": "string",41 "token": "string",42 "userid": "string"43 """44 @pytest.mark.parametrize(('login_phone', 'login_password', 'update_user_phone', 'update_user_password',45 'delete_except_message', 'delete_except_status',46 'login_except_message', 'login_except_status'),47 getter.load_yaml('SystemManagementData.yml')['test_sys_admin_delete']['test_sys_admin_delete_success'])48 def test_delete_success(self, login_phone, login_password, update_user_phone, update_user_password,49 delete_except_message, delete_except_status, login_except_message, login_except_status):50 with allure.step("step1: æ¥éª¤1 ==>> ç»å½å¹¶è·åtoken,userid,cookies"):51 token, userId, cookies = getter.get_login_token_cookies(login_phone, login_password, True)52 with allure.step("step2: æ¥éª¤2 ==>> ç»å½è¢«å é¤ç¨æ·ï¼è·å该ç¨æ·id"):53 update_user_id = getter.user_login(phone=update_user_phone, password=update_user_password,54 rememberMe=False).json()['data']['sysAdmin']['id']55 with allure.step("step3: æ¥éª¤3 ==>> å é¤å
¶ä»ç¨æ·"):56 rsp_delete = getter.user_delete(cookies, id=update_user_id, token=token, userid=userId)57 with allure.step("step4: æ¥éª¤4 ==>> ç»å½è¢«å é¤çç¨æ·è´¦å·"):58 rsp_login = getter.user_login(phone=update_user_phone, password=update_user_password, rememberMe=True)59 assert rsp_delete.status_code == 20060 assert rsp_delete.json()['data'] is None61 assert rsp_delete.json()['message'] == delete_except_message62 assert rsp_delete.json()['status'] == delete_except_status63 assert rsp_login.status_code == 20064 assert rsp_login.json()['data'] is None65 assert rsp_login.json()['message'] == login_except_message66 assert rsp_login.json()['status'] == login_except_status67if __name__ == '__main__':...
routes_user.py
Source:routes_user.py
...52 result = request.query.get('result', '')53 result = unquote_plus(result)54 body = JinjaTemplateRender.render('register.html', result=result)55 return html_response(body)56def update_user_password(request):57 # route_admin_update58 """59 管çåä¿®æ¹ç¨æ·ä¿¡æ¯60 """61 result = ''62 # åå°ç®¡çåè¾å
¥çç¨æ· id åæ°å¯ç 63 form = request.form()64 # éç½®å¯ç å ç65 salted_pw = str(User.salted_password(form['password']))66 # è°ç¨ User ç update æ¹æ³ï¼ä¿®æ¹ç¨æ·å¯ç 67 User.update(form, salted_pw)68 # è¿åå°ç®¡çåæ¥çç¨æ·ä¿¡æ¯ç页é¢69 result += 'password_modified'70 return redirect('/admin/edit_password?result={}'.format(result))...
urls.py
Source:urls.py
1from django.conf.urls import url2from . import views3urlpatterns = [4 url(r'^index/$', views.index, name='index'),5 url(r'^user_login/$', views.user_login, name='user_login'),6 url(r'^user_logout/$', views.user_logout, name='user_logout'),7 url(r'^user_register/$', views.user_register, name='user_register'),8 url(r'^user_self', views.user_self, name='user_self'),9 url(r'^update_user_self', views.update_user_self, name='update_user_self'),10 url(r'^update_user_header', views.update_user_header, name='update_user_header'),11 url(r'^update_user_password', views.update_user_password, name='update_user_password'),12 url(r'^goods_car/$', views.goods_car, name='goods_car'),13 url(r'^cancel_buy/(\d+)/$', views.cancel_buy, name='cancel_buy'),14 url(r'^send_msg/(\d+)/$', views.send_msg, name='send_msg'),15 url(r'^add_address/(\d+)/$', views.add_address, name='add_address'),16 url(r'^address_list/(\d+)/$', views.address_list, name='address_list'),17 url(r'^code/$', views.code, name='code'),18 url(r'^$', views.index)...
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!!