How to use page404 method in locust

Best Python code snippet using locust

admin_route.py

Source:admin_route.py Github

copy

Full Screen

1from run import app2from flask import request3from general_handle import sqli, output, token_handle4from Data_handle.admin import account, borrow, documents, category5###########6# Account #7###########8@app.route('/api/admin/users/all', methods=['POST', 'GET'])9def viewall_user():10 if sqli.check(request.args):11 return output.error("SQL Injection!")12 13 if 'token' in request.args:14 token = request.args['token']15 if (token_handle.checktoken(token)):16 return account.viewall(token)17 else:18 return output.error("Incorrect Token!")19 else:20 return output.page40421@app.route('/api/admin/users/create', methods=['POST', 'GET'])22def create_user():23 if sqli.check(request.args):24 return output.error("SQL Injection!")25 26 if 'token' in request.args and 'StudentID' in request.args and 'Password' in request.args and 'Fullname' in request.args and 'Specialization' in request.args and 'Class' in request.args and 'Admin' in request.args:27 token = request.args['token']28 StudentID = request.args['StudentID']29 Password = request.args['Password']30 Fullname = request.args['Fullname']31 Specialization = request.args['Specialization']32 Class = request.args['Class']33 Admin = request.args['Admin']34 if 'PhoneNumber' in request.args:35 PhoneNumber = request.args['PhoneNumber']36 else:37 PhoneNumber = "0"38 if (token_handle.checktoken(token)):39 return account.createuser(token, StudentID, Password, Fullname, PhoneNumber, Specialization, Class, Admin)40 else:41 return output.error("Incorrect Token!")42 else:43 return output.page40444@app.route('/api/admin/users/delete', methods=['POST', 'GET'])45def delete_user():46 if sqli.check(request.args):47 return output.error("SQL Injection!")48 49 if 'token' in request.args and 'StudentID' in request.args:50 token = request.args['token']51 StudentID = request.args['StudentID']52 if (token_handle.checktoken(token)):53 return account.deluser(token,StudentID)54 else:55 return output.error("Incorrect Token!")56 else:57 return output.page40458@app.route('/api/admin/users/disable', methods=['POST', 'GET'])59def disable_user():60 if sqli.check(request.args):61 return output.error("SQL Injection!")62 63 if 'token' in request.args and 'StudentID' in request.args:64 token = request.args['token']65 StudentID = request.args['StudentID']66 if (token_handle.checktoken(token)):67 return account.disableuser(token,StudentID)68 else:69 return output.error("Incorrect Token!")70 else:71 return output.page40472@app.route('/api/admin/users/active', methods=['POST', 'GET'])73def active_user():74 if sqli.check(request.args):75 return output.error("SQL Injection!")76 77 if 'token' in request.args and 'StudentID' in request.args:78 token = request.args['token']79 StudentID = request.args['StudentID']80 if (token_handle.checktoken(token)):81 return account.activeuser(token,StudentID)82 else:83 return output.error("Incorrect Token!")84 else:85 return output.page40486@app.route('/api/admin/users/update', methods=['POST', 'GET'])87def update_user():88 if sqli.check(request.args):89 return output.error("SQL Injection!")90 91 if 'token' in request.args and 'StudentID' in request.args and 'Password' in request.args and 'Fullname' in request.args and 'Specialization' in request.args and 'Class' in request.args and 'Expiry' in request.args:92 token = request.args['token']93 StudentID = request.args['StudentID']94 Password = request.args['Password']95 Fullname = request.args['Fullname']96 Specialization = request.args['Specialization']97 Class = request.args['Class']98 Expiry = request.args['Expiry']99 if 'PhoneNumber' in request.args:100 PhoneNumber = request.args['PhoneNumber']101 else:102 PhoneNumber = "0"103 if (token_handle.checktoken(token)):104 return account.update(token, StudentID, Password, Fullname, PhoneNumber, Specialization, Class, Expiry)105 else:106 return output.error("Incorrect Token!")107 else:108 return output.page404109@app.route('/api/admin/users/extend', methods=['POST', 'GET'])110def Extend():111 if sqli.check(request.args):112 return output.error("SQL Injection!")113 114 if 'token' in request.args and 'StudentID' in request.args and 'Expiry' in request.args:115 token = request.args['token']116 StudentID = request.args['StudentID']117 Expiry = request.args['Expiry']118 if (token_handle.checktoken(token)):119 return account.Extend(token, StudentID, Expiry)120 else:121 return output.error("Incorrect Token!")122 else:123 return output.page404124#############125# Documents #126#############127@app.route('/api/admin/documents/add', methods=['POST', 'GET'])128def add_documents():129 if sqli.check(request.args):130 return output.error("SQL Injection!")131 if 'token' in request.args and 'Name' in request.args and 'Author' in request.args and 'Description' in request.args and 'ListCategoryID' in request.args:132 token = request.args['token']133 Name = request.args['Name']134 Author = request.args['Author']135 Description = request.args['Description']136 ListCategoryID = request.args['ListCategoryID']137 if (token_handle.checktoken(token)):138 return documents.add(token, Name, Author, Description, ListCategoryID)139 else:140 return output.error("Incorrect Token!")141 else:142 return output.page404143@app.route('/api/admin/documents/delete', methods=['POST', 'GET'])144def delete_documents():145 if sqli.check(request.args):146 return output.error("SQL Injection!")147 if 'token' in request.args and 'DocumentsID' in request.args:148 token = request.args['token']149 DocumentsID = request.args['DocumentsID']150 if (token_handle.checktoken(token)):151 return documents.delete(token, DocumentsID)152 else:153 return output.error("Incorrect Token!")154 else:155 return output.page404156@app.route('/api/admin/documents/update', methods=['POST', 'GET'])157def update_documents():158 if sqli.check(request.args):159 return output.error("SQL Injection!")160 if 'token' in request.args and 'ID' in request.args and 'Name' in request.args and 'Author' in request.args and 'Description' in request.args and 'ListCategoryID' in request.args:161 token = request.args['token']162 ID = request.args['ID']163 Name = request.args['Name']164 Author = request.args['Author']165 Description = request.args['Description']166 ListCategoryID = request.args['ListCategoryID']167 if (token_handle.checktoken(token)):168 return documents.update(token, ID, Name, Author, Description, ListCategoryID)169 else:170 return output.error("Incorrect Token!")171 else:172 return output.page404173@app.route('/api/admin/documents/addDoc', methods=['POST', 'GET'])174def add_document():175 if sqli.check(request.args):176 return output.error("SQL Injection!")177 if 'token' in request.args and 'ID' in request.args and 'DocumentsID' in request.args and 'Reprint' in request.args and 'Price' in request.args:178 token = request.args['token']179 ID = request.args['ID']180 DocumentsID = request.args['DocumentsID']181 Reprint = request.args['Reprint']182 Price = request.args['Price']183 if (token_handle.checktoken(token)):184 return documents.addDoc(token, ID, DocumentsID, Reprint, Price)185 else:186 return output.error("Incorrect Token!")187 else:188 return output.page404189############190# Category #191############192@app.route('/api/admin/category/add', methods=['POST', 'GET'])193def add_category():194 if sqli.check(request.args):195 return output.error("SQL Injection!")196 if 'token' in request.args and 'Name' in request.args and 'Description' in request.args:197 token = request.args['token']198 Name = request.args['Name']199 Description = request.args['Description']200 if (token_handle.checktoken(token)):201 return category.add(token, Name, Description)202 else:203 return output.error("Incorrect Token!")204 else:205 return output.page404206@app.route('/api/admin/category/delete', methods=['POST', 'GET'])207def delete_category():208 if sqli.check(request.args):209 return output.error("SQL Injection!")210 if 'token' in request.args and 'ID' in request.args:211 token = request.args['token']212 ID = request.args['ID']213 if (token_handle.checktoken(token)):214 return category.delete(token, ID)215 else:216 return output.error("Incorrect Token!")217 else:218 return output.page404219@app.route('/api/admin/category/update', methods=['POST', 'GET'])220def update_category():221 if sqli.check(request.args):222 return output.error("SQL Injection!")223 if 'token' in request.args and 'ID' in request.args and 'Name' in request.args and 'Description' in request.args:224 token = request.args['token']225 ID = request.args['ID']226 Name = request.args['Name']227 Description = request.args['Description']228 if (token_handle.checktoken(token)):229 return category.update(token, ID, Name, Description)230 else:231 return output.error("Incorrect Token!")232 else:233 return output.page404234##########235# Borrow #236##########237@app.route('/api/admin/borrow/all', methods=['POST', 'GET'])238def viewall_borrow():239 if sqli.check(request.args):240 return output.error("SQL Injection!")241 242 if 'token' in request.args:243 token = request.args['token']244 if (token_handle.checktoken(token)):245 return borrow.viewall(token)246 else:247 return output.error("Incorrect Token!")248 else:249 return output.page404250@app.route('/api/admin/borrow/search', methods=['POST', 'GET'])251def searchbyStudentID():252 if sqli.check(request.args):253 return output.error("SQL Injection!")254 255 if 'token' in request.args and 'StudentID' in request.args:256 token = request.args['token']257 StudentID = request.args['StudentID']258 if (token_handle.checktoken(token)):259 return borrow.SearchbyStudentID(token, StudentID)260 else:261 return output.error("Incorrect Token!")262 else:263 return output.page404264@app.route('/api/admin/borrow/confirm', methods=['POST', 'GET'])265def confirm_borrow():266 if sqli.check(request.args):267 return output.error("SQL Injection!")268 269 if 'token' in request.args and 'borrowID' in request.args:270 token = request.args['token']271 borrowID = request.args['borrowID']272 if (token_handle.checktoken(token)):273 return borrow.confirm(token,borrowID)274 else:275 return output.error("Incorrect Token!")276 else:277 return output.page404278@app.route('/api/admin/borrow/return', methods=['POST', 'GET'])279def return_borrow():280 if sqli.check(request.args):281 return output.error("SQL Injection!")282 283 if 'token' in request.args and 'documentID' in request.args:284 token = request.args['token']285 documentID = request.args['documentID']286 if (token_handle.checktoken(token)):287 return borrow.returndocument(token,documentID)288 else:289 return output.error("Incorrect Token!")290 else:291 return output.page404292@app.route('/api/admin/borrow/lose', methods=['POST', 'GET'])293def lose_borrow():294 if sqli.check(request.args):295 return output.error("SQL Injection!")296 297 if 'token' in request.args and 'documentID' in request.args:298 token = request.args['token']299 documentID = request.args['documentID']300 if (token_handle.checktoken(token)):301 return borrow.lose(token,documentID)302 else:303 return output.error("Incorrect Token!")304 else:...

Full Screen

Full Screen

test_habr2.py

Source:test_habr2.py Github

copy

Full Screen

1import time2from random import randint3link = "https://habr.com/ru/all/page"4# проверка страниц с 1 по 505# number = 16# def test_guest_should_see_1_50_pages(browser):7# for number in range (1,51):8# browser.get(link + str(number))9# time.sleep(randint(1,3))10#проверка -1 страницы11def test_guest_should_see_minus1_page(browser):12 browser.get(link + str(-1))13 time.sleep(randint(1,3))14 page404 = browser.find_element_by_tag_name("h1").text15 assert "Страница не найдена" != page404, "Page not found"16#проверка 0 страницы17def test_guest_should_see_0_page(browser):18 browser.get(link + str(0))19 time.sleep(randint(1, 3))20 page404 = browser.find_element_by_tag_name("h1").text21 assert "Страница не найдена" != page404, "Page not found"22#проверка 1 страницы23def test_guest_should_see_1_page(browser):24 browser.get(link + str(1))25 time.sleep(randint(1, 3))26 page404 = browser.find_element_by_tag_name("h1").text27 assert "Страница не найдена" != page404, "Page not found"28#проверка 25 страницы29def test_guest_should_see_25_page(browser):30 browser.get(link + str(25))31 time.sleep(randint(1, 3))32 page404 = browser.find_element_by_tag_name("h1").text33 assert "Страница не найдена" != page404, "Page not found"34#проверка 49 страницы35def test_guest_should_see_49_page(browser):36 browser.get(link + str(49))37 time.sleep(randint(1, 3))38 page404 = browser.find_element_by_tag_name("h1").text39 assert "Страница не найдена" != page404, "Page not found"40#проверка 50 страницы41def test_guest_should_see_50_page(browser):42 browser.get(link + str(50))43 time.sleep(randint(1, 3))44 page404 = browser.find_element_by_tag_name("h1").text45 assert "Страница не найдена" != page404, "Page not found"46#проверка 51 страницы47def test_guest_should_see_51_page(browser):48 browser.get(link + str(51))49 time.sleep(randint(1, 3))50 page4041 = browser.find_element_by_css_selector("div.tm-articles-subpage > div > div > div > span").text...

Full Screen

Full Screen

test_Page404.py

Source:test_Page404.py Github

copy

Full Screen

1from Pages.DashboadPage import DashboardPage2from Pages.IndicesPage import IndicesPage3from Pages.Page404 import Page4044from Tests.Base import BaseTest5from Pages.LoginPage import LoginPage6from Pages.ConfigurationPage import ConfigurationPage7from Config.config import TestData8#test9class Test_Page404(BaseTest):10 def test_404_page_displaying_before_login_and_redirected_back_to_login(self):11 self.configpage = ConfigurationPage(self.driver)12 self.configpage.click_on_getStarted_button()13 self.page404 = Page404(self.driver)14 assert self.page404.access_non_exist_page()15 self.page404.click_go_to_login_button()16 self.loginpage = LoginPage(self.driver)17 assert self.loginpage.is_login_header_text_displaying()18 def test_404_page_displaying_after_login_on_indices_and_redirected_back_to_indices(self):19 self.configpage = ConfigurationPage(self.driver)20 self.loginpage = LoginPage(self.driver)21 self.configpage.click_on_getStarted_button()22 self.loginpage.do_login(TestData.USERNAME, TestData.PASSWORD)23 self.page404 = Page404(self.driver)24 assert self.page404.access_non_exist_page()25 self.page404.click_go_to_login_button()26 self.indicespage = IndicesPage(self.driver)27 assert self.indicespage.check_indices_header_text_displaying()28 def test_404_page_displaying_after_login_on_dashboard_and_redirected_back_to_dashboard(self):29 self.configpage = ConfigurationPage(self.driver)30 self.loginpage = LoginPage(self.driver)31 self.configpage.click_on_getStarted_button()32 self.loginpage.do_login(TestData.USERNAME, TestData.PASSWORD)33 self.indicespage = IndicesPage(self.driver)34 self.indicespage.index_pattern(TestData.INDEXPATTERN)35 self.indicespage.image_key_field(TestData.IMAGEKEYFIELD)36 self.indicespage.continue_button_click()37 self.page404 = Page404(self.driver)38 assert self.page404.access_non_exist_page()39 self.page404.click_go_to_login_button()40 self.dashboard = DashboardPage(self.driver)...

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