test: Added missing unit and integration tests#32
Open
usanvict wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds comprehensive unit and end-to-end test coverage for the Apify LangChain tools, targeting gaps not covered by the existing
test_tools.pyandtest_client.pysuites.New unit tests
test_clamping.py-- Tests_clamp_depth(previously untested), exact at-boundary values for all clamp functions (_clamp_timeout,_clamp_memory,_clamp_items,_clamp_depth), and relaxed custom limit pass-through.test_input_validation.py-- Exhaustive Pydantic input schema validation: missing required fields, wrong types, offset boundaries, empty/long string IDs, unicode/special characters, dict structure edge cases (deeply nested, None values, large dicts), URL format boundaries,ApifyDatasetLoaderconstructor validation, and confirmation that schemas intentionally defer range-checking to clamping.test_integration_mock.py-- Tests the LangChain.invoke()error-handling path (handle_tool_error=TrueconvertsToolExceptionto a string instead of raising) and verifies output key sets match the documented API contract forRunActor,RunActorAndGetDataset, andGetDatasetItems.test_run_meta.py-- Edge cases for the_run_meta()utility: empty dict returns all Nones, extra API keys are filtered out, and non-SUCCEEDEDstatuses (FAILED, TIMED-OUT, RUNNING, ABORTING) are preserved.test_two_step_orchestration.py-- Tests the RunActor -> GetDatasetItems two-step orchestration pattern: dataset_id flows correctly between steps, failed Step 1 produces non-JSON error output, and each run produces a unique dataset ID.New E2E integration tests
All E2E tests require
APIFY_API_TOKENand are automatically skipped when the token is not set.test_e2e_auth.py-- Missing token raisesValueError; invalid token returns a non-JSON error string.test_e2e_happy.py-- Happy-path coverage for all 6 core tools (RunActor,GetDatasetItems,RunActorAndGetDataset,ScrapeUrl,RunTask,RunTaskAndGetDataset) against the live Apify API usingapify/python-example.test_e2e_negative.py-- Parametrized test verifying that invalid actor/dataset/task IDs return graceful error strings (no exception propagation).test_e2e_stability.py-- Repeated invocations produce structurally consistent output shapes and unique dataset IDs; fetching the same dataset multiple times returns identical items.test_e2e_timeout.py-- Boundary conditions against the live API: offset beyond dataset returns empty, limit larger than dataset returns available items, and explicitmemory_mbytes=128is accepted.