|
17 | 17 | ExecutionResult,
|
18 | 18 | ResultMetadata,
|
19 | 19 | DuneError,
|
| 20 | + CreateTableResult, |
20 | 21 | )
|
21 | 22 | from dune_client.types import QueryParameter
|
22 | 23 | from dune_client.query import DuneQuery, QueryMeta, QueryBase
|
@@ -279,6 +280,33 @@ def test_dune_query_from_dict(self):
|
279 | 280 | )
|
280 | 281 | self.assertEqual(expected, DuneQuery.from_dict(json.loads(example_response)))
|
281 | 282 |
|
| 283 | + def test_create_table_result_with_already_existed_field(self): |
| 284 | + """Test CreateTableResult parsing when API response includes already_existed field""" |
| 285 | + response_data = { |
| 286 | + "namespace": "test_namespace", |
| 287 | + "table_name": "test_table", |
| 288 | + "full_name": "dune.test_namespace.test_table", |
| 289 | + "example_query": "select * from dune.test_namespace.test_table limit 10", |
| 290 | + "already_existed": False, |
| 291 | + "message": "Table created successfully", |
| 292 | + } |
| 293 | + result = CreateTableResult.from_dict(response_data) |
| 294 | + self.assertFalse(result.already_existed) |
| 295 | + |
| 296 | + def test_create_table_result_missing_already_existed_field(self): |
| 297 | + """Test CreateTableResult parsing when API response lacks already_existed field (verify default value)""" |
| 298 | + response_data = { |
| 299 | + "namespace": "test_namespace", |
| 300 | + "table_name": "test_table", |
| 301 | + "full_name": "dune.test_namespace.test_table", |
| 302 | + "example_query": "select * from dune.test_namespace.test_table limit 10", |
| 303 | + "message": "Table created successfully", |
| 304 | + # Note: intentionally omitting already_existed field |
| 305 | + } |
| 306 | + result = CreateTableResult.from_dict(response_data) |
| 307 | + # Verify default value is False |
| 308 | + self.assertFalse(result.already_existed) |
| 309 | + |
282 | 310 |
|
283 | 311 | if __name__ == "__main__":
|
284 | 312 | unittest.main()
|
0 commit comments