66from codex import AuthenticationError
77from codex .types .project_create_params import Config
88from codex .types .projects .access_key_retrieve_project_id_response import AccessKeyRetrieveProjectIDResponse
9+ from codex .types .projects .entry import Entry as SDKEntry
910
1011from cleanlab_codex .project import MissingProjectError , Project
11- from cleanlab_codex .types .entry import Entry , EntryCreate
12+ from cleanlab_codex .types .entry import EntryCreate
1213
1314FAKE_PROJECT_ID = str (uuid .uuid4 ())
1415FAKE_USER_ID = "Test User"
@@ -138,11 +139,12 @@ def test_query_read_only(mock_client_from_access_key: MagicMock) -> None:
138139 FAKE_PROJECT_ID , question = "What is the capital of France?"
139140 )
140141 mock_client_from_access_key .projects .entries .add_question .assert_not_called ()
141- assert res == (None , None )
142+ assert res [0 ] is None
143+ assert res [1 ] is None
142144
143145
144146def test_query_question_found_fallback_answer (mock_client_from_access_key : MagicMock ) -> None :
145- unanswered_entry = Entry (
147+ unanswered_entry = SDKEntry (
146148 id = str (uuid .uuid4 ()),
147149 created_at = datetime .now (tz = timezone .utc ),
148150 question = "What is the capital of France?" ,
@@ -151,22 +153,32 @@ def test_query_question_found_fallback_answer(mock_client_from_access_key: Magic
151153 mock_client_from_access_key .projects .entries .query .return_value = unanswered_entry
152154 project = Project (mock_client_from_access_key , FAKE_PROJECT_ID )
153155 res = project .query ("What is the capital of France?" )
154- assert res == (None , unanswered_entry )
156+ assert res [0 ] is None
157+ assert res [1 ] is not None
158+ assert res [1 ].model_dump () == unanswered_entry .model_dump ()
155159
156160
157161def test_query_question_not_found_fallback_answer (mock_client_from_access_key : MagicMock ) -> None :
158162 mock_client_from_access_key .projects .entries .query .return_value = None
159- mock_client_from_access_key .projects .entries .add_question .return_value = MagicMock (spec = Entry )
163+ mock_entry = SDKEntry (
164+ id = "fake-id" ,
165+ created_at = datetime .now (tz = timezone .utc ),
166+ question = "What is the capital of France?" ,
167+ answer = None ,
168+ )
169+ mock_client_from_access_key .projects .entries .add_question .return_value = mock_entry
160170
161171 project = Project (mock_client_from_access_key , FAKE_PROJECT_ID )
162172 res = project .query ("What is the capital of France?" , fallback_answer = "Paris" )
163173 assert res [0 ] == "Paris"
174+ assert res [1 ] is not None
175+ assert res [1 ].model_dump () == mock_entry .model_dump ()
164176
165177
166178def test_query_add_question_when_not_found (mock_client_from_access_key : MagicMock ) -> None :
167179 """Test that query adds question when not found and not read_only"""
168180 mock_client_from_access_key .projects .entries .query .return_value = None
169- new_entry = Entry (
181+ new_entry = SDKEntry (
170182 id = str (uuid .uuid4 ()),
171183 created_at = datetime .now (tz = timezone .utc ),
172184 question = "What is the capital of France?" ,
@@ -180,11 +192,13 @@ def test_query_add_question_when_not_found(mock_client_from_access_key: MagicMoc
180192 mock_client_from_access_key .projects .entries .add_question .assert_called_once_with (
181193 FAKE_PROJECT_ID , question = "What is the capital of France?"
182194 )
183- assert res == (None , new_entry )
195+ assert res [0 ] is None
196+ assert res [1 ] is not None
197+ assert res [1 ].model_dump () == new_entry .model_dump ()
184198
185199
186200def test_query_answer_found (mock_client_from_access_key : MagicMock ) -> None :
187- answered_entry = Entry (
201+ answered_entry = SDKEntry (
188202 id = str (uuid .uuid4 ()),
189203 created_at = datetime .now (tz = timezone .utc ),
190204 question = "What is the capital of France?" ,
@@ -193,7 +207,9 @@ def test_query_answer_found(mock_client_from_access_key: MagicMock) -> None:
193207 mock_client_from_access_key .projects .entries .query .return_value = answered_entry
194208 project = Project (mock_client_from_access_key , FAKE_PROJECT_ID )
195209 res = project .query ("What is the capital of France?" )
196- assert res == ("Paris" , answered_entry )
210+ assert res [0 ] == answered_entry .answer
211+ assert res [1 ] is not None
212+ assert res [1 ].model_dump () == answered_entry .model_dump ()
197213
198214
199215def test_add_entries_empty_list (mock_client_from_access_key : MagicMock ) -> None :
0 commit comments