test: implement unit tests for knowledge-space api logic #63#65
Open
ulekarsiddhant0-boop wants to merge 1 commit intoINCF:mainfrom
Open
test: implement unit tests for knowledge-space api logic #63#65ulekarsiddhant0-boop wants to merge 1 commit intoINCF:mainfrom
ulekarsiddhant0-boop wants to merge 1 commit intoINCF:mainfrom
Conversation
Author
|
Nice work on the KS API tests @ulekarsiddhant0-boop! These complement my PR #64 well — my tests cover the API endpoints (health, chat, session reset) while yours cover the internal KS API logic. One suggestion: it might be cleaner to place the tests inside |
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.

This PR addresses Issue #63 by implementing a comprehensive testing suite for the KnowledgeSpace API backend. It ensures that the data retrieval and formatting logic are reliable and handles edge cases appropriately.
Key Changes was :
1]Testing Infrastructure: Added init.py files to the backend/ and tests/ directories to enable standard Python module discovery.
2]API Mocking: Utilized pytest-mock to simulate external API responses from api.knowledge-space.org. This allows tests to run without an internet connection and prevents hitting rate limits.
3]Data Validation: Added unit tests for format_datasets_list and list_datasources to verify that JSON responses are correctly parsed into human-readable strings.
4]Edge Case Handling: Added a specific test case for empty search results to ensure the system returns a graceful "No datasets found" message rather than crashing.
Verification Results:
I have verified the changes locally using the following command:
python -m pytest tests/Result: 3 passed in 0.14s