wip, might not be good
This commit is contained in:
parent
f53879f961
commit
6d5bfaeeda
63 changed files with 1897 additions and 93 deletions
58
locustfile.py
Normal file
58
locustfile.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import random
|
||||
|
||||
from locust import FastHttpUser, task
|
||||
|
||||
from learn_sql_model.config import get_config
|
||||
from learn_sql_model.factories.hero import HeroFactory
|
||||
from learn_sql_model.models.hero import HeroCreate, HeroUpdate, Heros
|
||||
|
||||
config = get_config()
|
||||
|
||||
|
||||
class QuickstartUser(FastHttpUser):
|
||||
# wait_time = between(1, 2)
|
||||
host = "http://localhost:5000"
|
||||
# host = "https://waylonwalker.com"
|
||||
|
||||
def on_start(self):
|
||||
self.client.verify = False
|
||||
|
||||
@task(6)
|
||||
def get_a_hero(self):
|
||||
# heros = Heros.list()
|
||||
id = 1
|
||||
# id = random.choice(heros.__root__).id
|
||||
|
||||
self.client.get(f"/hero/{id}")
|
||||
|
||||
# @task(2)
|
||||
# def get_all_hero(self):
|
||||
# self.client.get("/heros/")
|
||||
|
||||
@task
|
||||
def create_hero(self):
|
||||
hero = HeroFactory().build()
|
||||
hero_create = HeroCreate(**hero.dict()).post()
|
||||
|
||||
self.client.post(
|
||||
f"{config.api_client.url}/hero/",
|
||||
json=hero_create.dict(),
|
||||
)
|
||||
|
||||
@task(3)
|
||||
def update_hero(self):
|
||||
hero = HeroFactory().build()
|
||||
hero_update = HeroUpdate(id=1, name=hero.name)
|
||||
|
||||
self.client.patch(
|
||||
"/hero/",
|
||||
json=hero_update.dict(exclude_none=True),
|
||||
)
|
||||
|
||||
@task
|
||||
def delete_hero(self):
|
||||
heros = Heros.list()
|
||||
id = random.choice(heros.__root__).id
|
||||
self.client.delete(
|
||||
f"/hero/{id}",
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue