Created
October 27, 2017 13:27
-
-
Save jamesperes-zz/1eac535b439f48230c7496d7da745049 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from locust import HttpLocust, TaskSet, task | |
import requests | |
class UserActions(TaskSet): | |
def login(self): | |
# login to the application | |
response = self.client.get('/auth/login') | |
#self.client.headers['Referer'] = self.client.base_url | |
csrftoken = response.cookies['csrftoken'] | |
#print(response) | |
#print(csrftoken) | |
self.client.post('/auth/login', | |
{'username': 'james', 'password': 'teste'}, | |
headers={'X-CSRFToken': csrftoken}) | |
def on_start(self): | |
self.login() | |
@task(1) | |
def index(self): | |
self.client.get('/home') | |
for i in range(4): | |
@task(2) | |
def first_page(self): | |
tela = self.client.get('/auth/profile?id=2') | |
print(tela.content.decode('utf-8')) | |
class ApplicationUser(HttpLocust): | |
task_set = UserActions | |
min_wait = 0 | |
max_wait = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment