Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions integration-tests/test_upsert_graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import pytest
import asyncio
import threading
Comment thread
NiveditJain marked this conversation as resolved.
from pydantic import BaseModel
Comment thread
NiveditJain marked this conversation as resolved.
from exospherehost import BaseNode, Runtime, StateManager, GraphNodeModel

@pytest.mark.asyncio
async def test_upsert_graph(running_server):

class PrintNode(BaseNode):
class Inputs(BaseModel):
message: str

async def execute(self):
print(self.inputs.message) # type: ignore

Comment thread
NiveditJain marked this conversation as resolved.

state_machine_url = running_server.base_url
Comment thread
NiveditJain marked this conversation as resolved.
runtime = Runtime(
namespace="test",
name="test",
nodes=[
PrintNode
],
state_manager_uri=state_machine_url,
)

thread = threading.Thread(target=runtime.start, daemon=True)
thread.start()

await asyncio.sleep(2)

state_manager = StateManager(
namespace="test",
state_manager_uri=state_machine_url,
)

data = await state_manager.upsert_graph(
graph_name="test_graph",
graph_nodes=[
GraphNodeModel(
Comment thread
NiveditJain marked this conversation as resolved.
node_name="PrintNode",
namespace="test",
identifier="node1",
inputs={
"message": "Hello, world!",
},
)
],
secrets={},
)

assert data is not None
Loading