Skip to content

Conversation

@Sumeet213
Copy link
Contributor

Fixes #290

Problem

Some tests were creating and deleting Notion resources manually. When tests failed, the cleanup code never ran, leaving resources behind in Notion.

Solution

Refactored tests to use pytest fixtures with yield for guaranteed cleanup. The cleanup code after yield always runs, even if the test fails.

Changes

  • Added 3 new fixtures in conftest.py:

    • multiple_test_pages - Creates 5 test pages for pagination tests
    • async_multiple_test_pages - Async version of above
    • async_test_data_source - Creates database and data source for testing
  • Updated 5 problematic tests to use fixtures instead of inline resource management:

    • test_iterate_paginated_api
    • test_async_iterate_paginated_api
    • test_async_iterate_data_source_templates
    • test_async_collect_data_source_templates

These are the ones I noticed , happy to update more if the maintainers know of others.

Add pytest fixtures with guaranteed cleanup to replace inline resource
creation/deletion. Ensures tests are idempotent with no side effects.
@codecov
Copy link

codecov bot commented Oct 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.50%. Comparing base (7b467fe) to head (6c5d511).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #291   +/-   ##
=======================================
  Coverage   99.50%   99.50%           
=======================================
  Files           7        7           
  Lines         401      401           
=======================================
  Hits          399      399           
  Misses          2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ramnes ramnes merged commit 3971c56 into ramnes:main Oct 27, 2025
9 checks passed
@ramnes
Copy link
Owner

ramnes commented Oct 27, 2025

Great, thanks!

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.

Implement more fixtures

2 participants