Pytest to Locust

I want to use this pytest script as a performance test.

How can I implement i.e. Userclass and tasks given the following script?

With regards to scope, if I define a UserClass (i.e. FastHttpUser), could all the test be outside of this class?

import requests
from azure.identity import DefaultAzureCredential
import json
import pytest

# Arrange:
base_url = "https://example.com"

credential = DefaultAzureCredential()
token = credential.get_token("api://xxx")
token = token.token

hpsId = ''
powerplantId = ''
all_pp_ids = []


def get_requests(t, endpoint):
    # Arrange:
    response = requests.get(f'{base_url}{endpoint}',
                    headers={"Authorization": f'Bearer {t}', 
   "Content-Type": 'application/json'})
    print(response.text)
    return response


def post_requests(t, endpoint, payload):
    # Arrange:
    data = payload
    json_data = json.dumps(data, indent=2)
    response = requests.post(f'{base_url}{endpoint}', data=json_data,
                     headers={"Authorization": f'Bearer {t}', 
   "Content-Type": 'application/json'})
   print(response.text)
   print(response.request.body)
   return response


def setpayload_bid_generate(hps_id):
    # Arrange:
    myjson = {"powerPlantIds": [hps_id]}
   return myjson


def setpayload_bids(hps_id, pp_id):
    # Arrange:
    myjson = {
        "hpsId": hps_id,
        "powerPlantId": pp_id,
        "readPeriod": [
            1713909600,
            1714089600
        ],
        "timeAxis": {
            "t0": 1713909600,
            "dt": 900,
            "n": 200
        }
    }
    return myjson


def setpayload_bids_generate_all(alle):
    # Arrange:
    myjson = {"powerPlantIds": alle}
    return myjson


def test_get_powerplant():
    global hpsId
    global powerplantId
    global all_pp_ids

    # Act:
    response = get_requests(token, '/mfrr- 
    eam/api/mfrr/eam/powerplant/all')
    try:
        data = response.json()
        all_pp_ids = [(item["powerPlant"]["id"]) for item in data]
        print("Alle powerplant IDs: ", all_pp_ids)
    except KeyError:
        print("Unable to get pp ids")

    try:
        hpsId = response.json()[0]["hpsId"]  # Get the hpsId
        print("HPS Ids: ", hpsId)
        print(response.text)
    except KeyError:
        print("Unable to get hpsID")
    try:
        powerplantId = response.json()[0]["powerPlant"]["id"]  
   # Get the powerplant id
        print("PP Ids: ", powerplantId)
    except KeyError:
       print("Unable to get powerplantId")
   # Assertion:
    assert response.status_code == 200  # Validation of status code


def test_bid_generate_for_powerplant():
   # Act:
   response = post_requests(token, '/mfrr- eam/api/mfrr/eam/bids/generate', 
   setpayload_bid_generate(hpsId))
  # Assertion:
  assert response.status_code == 200  # Validation of status code


def test_bids():
  # Act:
  response = post_requests(token, '/mfrr-eam/api/mfrr/eam/Bids', setpayload_bids(hpsId, 
  powerplantId))
  # Assertion:
  assert response.status_code == 200  # Validation of status code
    print("Responsen fra Bids: ", response.text)


 def test_bids_generate_all():
     # Act:
     response = post_requests(token, '/mfrr- 
     eam/api/mfrr/eam/bids/generate', 
     setpayload_bid_generate(all_pp_ids))
     # Assertion:
     assert response.status_code == 200  # Validation of status code

Shoudl every pytest-call be in a separate task? Or could it be all the test can be ran consecutively within the same task?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật