Skip to content

Comments

test: implement unit tests for knowledge-space api logic #63#65

Open
ulekarsiddhant0-boop wants to merge 1 commit intoINCF:mainfrom
ulekarsiddhant0-boop:feat/add-unit-tests-63
Open

test: implement unit tests for knowledge-space api logic #63#65
ulekarsiddhant0-boop wants to merge 1 commit intoINCF:mainfrom
ulekarsiddhant0-boop:feat/add-unit-tests-63

Conversation

@ulekarsiddhant0-boop
Copy link

@ulekarsiddhant0-boop ulekarsiddhant0-boop commented Feb 18, 2026

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

@ulekarsiddhant0-boop
Copy link
Author

Screenshot 2026-02-18 183545

@SandeepChauhan00
Copy link

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 backend/tests/ (same directory structure as PR #64) rather than a separate tests/ folder, so all backend tests stay together. That way both PRs can coexist once merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants