Skip to content

Conversation

@NakulSingh156
Copy link

@NakulSingh156 NakulSingh156 commented Jan 21, 2026

Pull Request

Description

Addressing the advanced requirement in Issue #20: "Create a local dummy Databus for testing core functionality offline."

Currently, tests depend on the live Databus, making them brittle and dependent on internet access. I have implemented a mock_databus fixture in conftest.py to solve this.

Features:
Ephemeral Port Binding: Automatically finds a free port (binds to localhost:0) to avoid conflicts.
Threaded Execution: Runs the HTTPServer in a background daemon thread.
Fixture Integration: Returns the dynamic base URL (e.g., http://localhost:58074) directly to tests.
Proof of Concept: Added tests/test_download_mock.py to verify the mock server handles requests and returns 404s correctly.
Terminal output showing the Mock Server starting on a random port and handling a request:

Screenshot 2026-01-22 at 4 50 29 AM

This provides the infrastructure needed to rewrite the download tests (Issue #20) without external dependencies.

Related Issues
Part of #20

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • This change requires a documentation update
  • Housekeeping

Checklist:

  • My code follows the ruff code style of this project.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
    • poetry run pytest - all tests passed
    • poetry run ruff check - no linting errors

Summary by CodeRabbit

Tests

  • Implemented mock databus server infrastructure for improved local testing
  • Added regression tests for content variant handling and deployment workflows
  • Enhanced test coverage with connectivity validation and error-handling checks

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

📝 Walkthrough

Walkthrough

This PR adds mock databus server test infrastructure in conftest.py with an HTTP server fixture, introduces tests to verify the mock server's connectivity and error handling, updates deployment tests with new API signatures and expected behavior, and removes debug behavior from SPARQLWrapper mocking.

Changes

Cohort / File(s) Summary
Test Infrastructure Setup
tests/conftest.py
Added MockDatabusHandler and session-scoped mock_databus fixture providing a free port HTTP server for test file serving. Removed R() return from SPARQLWrapper query() mock method.
Deployment Test Updates
tests/test_deploy.py
Added regression test for _get_content_variants empty case, un-skipped test_distribution_cases with behavior updates for "none" variant handling and dynamic checksum fetching, and revised test_empty_cvs expectations for modified graph structure in distribution JSON (updated IDs, types, and fields). Updated get_file_info call signature from (artifact_name, dst_string) to (dst_string).
Mock Databus Connectivity Tests
tests/test_download_mock.py
Added two tests verifying mock databus functionality: test_mock_databus_connection validates 200 response and plaintext content at /test-file.txt, and test_mock_download_404 verifies 404 handling for non-existent files.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • dbpedia/databus-python-client#39: Refactored get_file_info in databusclient.api.deploy module; the test updates in this PR reflect the resulting API signature change from (artifact_name, dst_string) to (dst_string).
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: implementing a local mock Databus server for offline testing, which is the primary objective of this PR.
Description check ✅ Passed The description comprehensively covers the PR objectives, features, related issues, and includes all required checklist items with appropriate selections and checks.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant