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