generated from Luis/nextjs-python-web-template
backend with --emulate flag
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import random
|
||||
import time
|
||||
import uuid
|
||||
import api
|
||||
|
||||
from openapi_client import ApiClient
|
||||
from openapi_client.api import DefaultApi
|
||||
@@ -14,18 +13,20 @@ from openapi_client.models import (
|
||||
Eventmessage,
|
||||
EventmessageCreate,
|
||||
Machine,
|
||||
Roles,
|
||||
ServiceCreate,
|
||||
Status,
|
||||
Roles,
|
||||
)
|
||||
|
||||
import config
|
||||
|
||||
random.seed(42)
|
||||
|
||||
#is linked to the emulate_fastapi.py and api.py
|
||||
host = api.host
|
||||
port_dlg = api.port_dlg
|
||||
port_ap = api.port_ap
|
||||
port_client_base = api.port_client_base
|
||||
|
||||
host = config.host
|
||||
port_dlg = config.port_dlg
|
||||
port_ap = config.port_ap
|
||||
port_client_base = config.port_client_base
|
||||
|
||||
num_uuids = 100
|
||||
uuids = [str(uuid.UUID(int=random.getrandbits(128))) for i in range(num_uuids)]
|
||||
@@ -44,7 +45,7 @@ def create_entities(num: int = 10) -> list[EntityCreate]:
|
||||
did=f"did:sov:test:12{i}",
|
||||
name=f"C{i}",
|
||||
ip=f"{host}:{port_client_base+i}",
|
||||
network=f"255.255.0.0",
|
||||
network="255.255.0.0",
|
||||
role=Roles("service_prosumer"),
|
||||
visible=True,
|
||||
other={},
|
||||
@@ -52,9 +53,9 @@ def create_entities(num: int = 10) -> list[EntityCreate]:
|
||||
res.append(en)
|
||||
dlg = EntityCreate(
|
||||
did=f"did:sov:test:{port_dlg}",
|
||||
name=f"DLG",
|
||||
name="DLG",
|
||||
ip=f"{host}:{port_dlg}/health",
|
||||
network=f"255.255.0.0",
|
||||
network="255.255.0.0",
|
||||
role=Roles("DLG"),
|
||||
visible=True,
|
||||
other={},
|
||||
@@ -62,9 +63,9 @@ def create_entities(num: int = 10) -> list[EntityCreate]:
|
||||
res.append(dlg)
|
||||
ap = EntityCreate(
|
||||
did=f"did:sov:test:{port_ap}",
|
||||
name=f"AP",
|
||||
name="AP",
|
||||
ip=f"{host}:{port_ap}/health",
|
||||
network=f"255.255.0.0",
|
||||
network="255.255.0.0",
|
||||
role=Roles("AP"),
|
||||
visible=True,
|
||||
other={},
|
||||
@@ -168,4 +169,4 @@ def test_create_eventmessages(api_client: ApiClient) -> None:
|
||||
res: Eventmessage = api.create_eventmessage(own_eventmsg)
|
||||
# breakpoint()
|
||||
assert res.id == own_eventmsg.id
|
||||
assert [] != api.get_all_eventmessages()
|
||||
assert [] != api.get_all_eventmessages()
|
||||
|
||||
Reference in New Issue
Block a user