Skip to content

test: mock external network dependencies in supabase integration tests#1646

Open
Neelr1912 wants to merge 6 commits into
leonagoel:mainfrom
Neelr1912:test/mock-supabase-network-dependencies
Open

test: mock external network dependencies in supabase integration tests#1646
Neelr1912 wants to merge 6 commits into
leonagoel:mainfrom
Neelr1912:test/mock-supabase-network-dependencies

Conversation

@Neelr1912

Copy link
Copy Markdown

Description

This PR resolves Issue #886 by ensuring Supabase-related tests are fully isolated from external network dependencies.

Changes

  • Added tests/test_supabase_gateway.py

    • Verifies Supabase client initialization
    • Tests successful and failed authentication flows
    • Tests successful and failed database query execution
    • Uses unittest.mock to prevent real network activity
  • Updated tests/test_import_to_supabase.py

    • Corrected the monkeypatch target to src.data.db.get_supabase_admin
    • Ensures tests use mocked Supabase clients instead of live connections

Benefits

  • No real Supabase requests during test execution
  • Deterministic and CI-friendly test suite
  • Reduced flakiness caused by network availability, credentials, or external service changes
  • Faster test execution

Testing

pytest tests/test_supabase_gateway.py
pytest tests/test_import_to_supabase.py

Both test suites pass successfully using mocked Supabase dependencies.

@github-actions

Copy link
Copy Markdown

🎉 Welcome to Hybrid Recommender, @Neelr1912!

Thank you for your first pull request! Here's what happens next:

Step What Who
1 CI runs lint + smoke test 🤖 Automated
2 Code review 👤 @leonagoel
3 mentor:leonagoel label added 👤 Mentor
4 gssoc:approved label added 👤 Mentor
5 Auto-merge triggered 🤖 Automated
6 Points on leaderboard at 4 AM IST 🏆 GSSoC

⏱️ Please respond to any review comments within 48 hours.

📖 Resources:

Happy contributing! 🚀

@github-actions

Copy link
Copy Markdown

🎉 Welcome to Hybrid Recommender, @Neelr1912! This is your first contribution here!

Labels added: gssoc:approved | mentor:leonagoel | status:review-needed

PR Description Checklist:

NO - What changed section
NO - Why section
NO - How to test section
NO - Related issue linked

⚠️ Some required sections are missing. Please update your PR description.

What happens next:

  1. @leonagoel will review your changes
  2. CI checks must pass
  3. Once approved, this PR will be auto-merged

⏱️ Please respond to review comments within 48 hours.

@Neelr1912

Copy link
Copy Markdown
Author

Hi @prakshithamalla-art,

I've opened a PR addressing this issue.

What was changed

  • Added dedicated tests to mock Supabase client interactions.
  • Ensured authentication and database operations are tested without making real network calls.
  • Updated the existing import test to patch the correct Supabase client target.
  • Verified that tests run deterministically without requiring live Supabase credentials or network access.

Validation

  • Added coverage for successful and failed authentication flows.
  • Added coverage for database query success and failure scenarios.
  • Confirmed CI checks are passing after resolving repository-wide issues encountered during validation.

Looking forward to any feedback. Thanks!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants