-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_payload_builder.py
More file actions
48 lines (40 loc) · 1.53 KB
/
test_payload_builder.py
File metadata and controls
48 lines (40 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""Tests for CuePayload builder."""
from cueapi.payload import CuePayload
class TestPayloadBuilder:
def test_basic(self):
payload = CuePayload().task("morning-brief").build()
assert payload == {"task": "morning-brief"}
def test_full(self):
payload = (
CuePayload()
.task("morning-brief")
.kind("content_generation")
.instruction("Generate the morning briefing")
.context_ref("mem_abc123")
.context_mode("isolated")
.agent("socrates")
.build()
)
assert payload["task"] == "morning-brief"
assert payload["kind"] == "content_generation"
assert payload["agent"] == "socrates"
assert payload["context_mode"] == "isolated"
assert payload["instruction"] == "Generate the morning briefing"
assert payload["context_ref"] == "mem_abc123"
assert len(payload) == 6
def test_extra_field(self):
payload = CuePayload().task("sync").extra("region", "us-east-1").build()
assert payload["region"] == "us-east-1"
def test_chaining(self):
p = CuePayload()
result = p.task("test")
assert result is p # verify fluent chaining returns self
def test_empty_build(self):
payload = CuePayload().build()
assert payload == {}
def test_build_returns_copy(self):
p = CuePayload().task("test")
d1 = p.build()
d2 = p.build()
assert d1 == d2
assert d1 is not d2 # separate dict instances