-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_predicate_api_key_aliases.py
More file actions
38 lines (29 loc) · 1.3 KB
/
test_predicate_api_key_aliases.py
File metadata and controls
38 lines (29 loc) · 1.3 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
# pylint: disable=protected-access
from unittest.mock import MagicMock
from predicate.agent_runtime import AgentRuntime
from predicate.models import SnapshotOptions
def test_snapshot_options_accepts_predicate_api_key() -> None:
opts = SnapshotOptions(predicate_api_key="pk_test")
assert opts.predicate_api_key == "pk_test"
assert opts.sentience_api_key == "pk_test"
def test_snapshot_options_keeps_backward_compatible_sentience_api_key() -> None:
opts = SnapshotOptions(sentience_api_key="sk_test")
assert opts.sentience_api_key == "sk_test"
assert opts.predicate_api_key == "sk_test"
def test_agent_runtime_accepts_predicate_api_key() -> None:
runtime = AgentRuntime(
backend=MagicMock(),
tracer=MagicMock(),
predicate_api_key="pk_runtime",
)
assert runtime._snapshot_options.predicate_api_key == "pk_runtime"
assert runtime._snapshot_options.sentience_api_key == "pk_runtime"
def test_agent_runtime_prefers_predicate_api_key_when_both_provided() -> None:
runtime = AgentRuntime(
backend=MagicMock(),
tracer=MagicMock(),
predicate_api_key="pk_new",
sentience_api_key="sk_old",
)
assert runtime._snapshot_options.predicate_api_key == "pk_new"
assert runtime._snapshot_options.sentience_api_key == "pk_new"