fix: make tests work with projects
This commit is contained in:
parent
551c51ec95
commit
d9befc076e
@ -7,6 +7,9 @@ import random
|
||||
|
||||
|
||||
class VikunjaTaskSet(TaskSequence):
|
||||
|
||||
project_ids = []
|
||||
|
||||
def on_start(self):
|
||||
# Called everytime when a simulated user starts executing TaskSet class
|
||||
self.headers = {
|
||||
@ -17,8 +20,7 @@ class VikunjaTaskSet(TaskSequence):
|
||||
|
||||
# Append your login or authentication keys to header
|
||||
self.get_authentication_keys()
|
||||
self.listIDs = []
|
||||
self.namespaces = {}
|
||||
self.projects = {}
|
||||
|
||||
def get_authentication_keys(self):
|
||||
response = self.client.post("/login", '{"username":"testuser' + str(random.randint(1, 100)) + '", "password":"1234"}', headers=self.headers)
|
||||
@ -29,29 +31,29 @@ class VikunjaTaskSet(TaskSequence):
|
||||
@task(25)
|
||||
def dashboard(self):
|
||||
self.client.get("/tasks/all", headers=self.headers)
|
||||
response = self.client.get("/namespaces", headers=self.headers)
|
||||
self.namespaces = json.loads(response.text)
|
||||
response = self.client.get("/projects", headers=self.headers)
|
||||
self.projects = json.loads(response.text)
|
||||
|
||||
@seq_task(2)
|
||||
@task(50) # 10 new lists
|
||||
def new_list(self):
|
||||
response = self.client.put("/namespaces/" + str(self.namespaces[0]["id"]) + "/lists",
|
||||
data=json.dumps({"title": "created by locust"}),
|
||||
@task(50)
|
||||
def new_project(self):
|
||||
response = self.client.put("/projects/",
|
||||
data=json.dumps({"title": "project created by locust"}),
|
||||
headers=self.headers)
|
||||
data = json.loads(response.text)
|
||||
self.listIDs.append(data["id"])
|
||||
self.project_ids.append(data["id"])
|
||||
|
||||
@seq_task(3)
|
||||
@task(500)
|
||||
def add_task(self):
|
||||
self.client.put("/lists/" + str(random.choice(self.listIDs)),
|
||||
self.client.put("/projects/" + str(random.choice(self.project_ids)) + "/tasks/",
|
||||
data=json.dumps({"text": "task created by locust"}),
|
||||
headers=self.headers)
|
||||
|
||||
@seq_task(4)
|
||||
@task(2000)
|
||||
def get_list(self):
|
||||
self.client.get("/lists/" + str(random.choice(self.listIDs)),
|
||||
def get_project(self):
|
||||
self.client.get("/projects/" + str(random.choice(self.project_ids)),
|
||||
headers=self.headers)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user