Skip to content

Commit cf75322

Browse files
Lingling PengLingling Peng
authored andcommitted
fix sync file
1 parent 7684440 commit cf75322

File tree

1 file changed

+34
-25
lines changed

1 file changed

+34
-25
lines changed

tests/integration/synapseclient/models/synchronous/test_agent.py

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
# The Bedrock agent is hosted on Sage Bionetworks AWS infrastructure.
1212
# CFN Template:
1313
# https://raw.githubusercontent.com/Sage-Bionetworks-Workflows/dpe-agents/refs/heads/main/client_integration_test/template.json
14-
CLOUD_AGENT_ID = "QOTV3KQM1X"
15-
AGENT_REGISTRATION_ID = "29"
14+
AGENT_AWS_ID = "QOTV3KQM1X"
1615

1716

1817
class TestAgentSession:
@@ -21,10 +20,14 @@ class TestAgentSession:
2120
@pytest.fixture(autouse=True, scope="function")
2221
def init(self, syn: Synapse) -> None:
2322
self.syn = syn
23+
if syn.repoEndpoint == "https://repo-dev.dev.sagebase.org/repo/v1":
24+
self.AGENT_REGISTRATION_ID = "7"
25+
else:
26+
self.AGENT_REGISTRATION_ID = "29"
2427

2528
async def test_start(self) -> None:
2629
# GIVEN an agent session with a valid agent registration id
27-
agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID)
30+
agent_session = AgentSession(agent_registration_id=self.AGENT_REGISTRATION_ID)
2831

2932
# WHEN the start method is called
3033
result_session = agent_session.start(synapse_client=self.syn)
@@ -38,13 +41,13 @@ async def test_start(self) -> None:
3841
assert result_session.started_on is not None
3942
assert result_session.started_by is not None
4043
assert result_session.modified_on is not None
41-
assert result_session.agent_registration_id == str(AGENT_REGISTRATION_ID)
44+
assert result_session.agent_registration_id == str(self.AGENT_REGISTRATION_ID)
4245
assert result_session.etag is not None
4346
assert result_session.chat_history == []
4447

4548
async def test_get(self) -> None:
4649
# GIVEN an agent session with a valid agent registration id
47-
agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID)
50+
agent_session = AgentSession(agent_registration_id=self.AGENT_REGISTRATION_ID)
4851
# WHEN I start a session
4952
agent_session.start(synapse_client=self.syn)
5053
# THEN I expect to be able to get the session with its id
@@ -54,7 +57,7 @@ async def test_get(self) -> None:
5457
async def test_update(self) -> None:
5558
# GIVEN an agent session with a valid agent registration id and access level set
5659
agent_session = AgentSession(
57-
agent_registration_id=AGENT_REGISTRATION_ID,
60+
agent_registration_id=self.AGENT_REGISTRATION_ID,
5861
access_level=AgentSessionAccessLevel.PUBLICLY_ACCESSIBLE,
5962
)
6063
# WHEN I start a session
@@ -71,7 +74,7 @@ async def test_update(self) -> None:
7174

7275
async def test_prompt(self) -> None:
7376
# GIVEN an agent session with a valid agent registration id
74-
agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID)
77+
agent_session = AgentSession(agent_registration_id=self.AGENT_REGISTRATION_ID)
7578
# WHEN I start a session
7679
agent_session.start(synapse_client=self.syn)
7780
# THEN I expect to be able to prompt the agent
@@ -89,37 +92,43 @@ async def test_prompt(self) -> None:
8992
class TestAgent:
9093
"""Integration tests for the synchronous methods of the Agent class."""
9194

92-
def get_test_agent(self) -> Agent:
93-
return Agent(
94-
cloud_agent_id=CLOUD_AGENT_ID,
95+
@pytest.fixture(autouse=True, scope="function")
96+
def init(self, syn: Synapse) -> None:
97+
self.syn = syn
98+
99+
if syn.repoEndpoint == "https://repo-dev.dev.sagebase.org/repo/v1":
100+
self.AGENT_REGISTRATION_ID = "7"
101+
registered_on = "2025-08-11T20:39:35.355Z"
102+
else:
103+
self.AGENT_REGISTRATION_ID = "29"
104+
registered_on = "2025-01-16T18:57:35.680Z"
105+
106+
self.agent = Agent(
107+
cloud_agent_id=AGENT_AWS_ID,
95108
cloud_alias_id="TSTALIASID",
96-
registration_id=AGENT_REGISTRATION_ID,
97-
registered_on="2025-01-16T18:57:35.680Z",
109+
registration_id=self.AGENT_REGISTRATION_ID,
110+
registered_on=registered_on,
98111
type="CUSTOM",
99112
sessions={},
100113
current_session=None,
101114
)
102115

103-
@pytest.fixture(autouse=True, scope="function")
104-
def init(self, syn: Synapse) -> None:
105-
self.syn = syn
106-
107116
async def test_register(self) -> None:
108117
# GIVEN an Agent with a valid agent AWS id
109-
agent = Agent(cloud_agent_id=CLOUD_AGENT_ID)
118+
agent = Agent(cloud_agent_id=AGENT_AWS_ID)
110119
# WHEN I register the agent
111120
agent.register(synapse_client=self.syn)
112121
# THEN I expect the agent to be registered
113-
expected_agent = self.get_test_agent()
122+
expected_agent = self.agent
114123
assert agent == expected_agent
115124

116125
async def test_get(self) -> None:
117126
# GIVEN an Agent with a valid agent registration id
118-
agent = Agent(registration_id=AGENT_REGISTRATION_ID)
127+
agent = Agent(registration_id=self.AGENT_REGISTRATION_ID)
119128
# WHEN I get the agent
120129
agent.get(synapse_client=self.syn)
121130
# THEN I expect the agent to be returned
122-
expected_agent = self.get_test_agent()
131+
expected_agent = self.agent
123132
assert agent == expected_agent
124133

125134
async def test_get_no_registration_id(self) -> None:
@@ -131,7 +140,7 @@ async def test_get_no_registration_id(self) -> None:
131140

132141
async def test_start_session(self) -> None:
133142
# GIVEN an Agent with a valid agent registration id
134-
agent = Agent(registration_id=AGENT_REGISTRATION_ID).get(
143+
agent = Agent(registration_id=self.AGENT_REGISTRATION_ID).get(
135144
synapse_client=self.syn
136145
)
137146
# WHEN I start a session
@@ -143,7 +152,7 @@ async def test_start_session(self) -> None:
143152

144153
async def test_get_session(self) -> None:
145154
# GIVEN an Agent with a valid agent registration id
146-
agent = Agent(registration_id=AGENT_REGISTRATION_ID).get(
155+
agent = Agent(registration_id=self.AGENT_REGISTRATION_ID).get(
147156
synapse_client=self.syn
148157
)
149158
# WHEN I start a session
@@ -157,11 +166,11 @@ async def test_get_session(self) -> None:
157166

158167
async def test_prompt_with_session(self) -> None:
159168
# GIVEN an Agent with a valid agent registration id
160-
agent = Agent(registration_id=AGENT_REGISTRATION_ID).get(
169+
agent = Agent(registration_id=self.AGENT_REGISTRATION_ID).get(
161170
synapse_client=self.syn
162171
)
163172
# AND a session started separately
164-
session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID).start(
173+
session = AgentSession(agent_registration_id=self.AGENT_REGISTRATION_ID).start(
165174
synapse_client=self.syn
166175
)
167176
# WHEN I prompt the agent with a session
@@ -177,7 +186,7 @@ async def test_prompt_with_session(self) -> None:
177186

178187
async def test_prompt_no_session(self) -> None:
179188
# GIVEN an Agent with a valid agent registration id
180-
agent = Agent(registration_id=AGENT_REGISTRATION_ID).get(
189+
agent = Agent(registration_id=self.AGENT_REGISTRATION_ID).get(
181190
synapse_client=self.syn
182191
)
183192
# WHEN I prompt the agent without a current session set

0 commit comments

Comments
 (0)