Skip to content

[WIP] Audit and Refactor Tests to Follow Pytest Conventions#3

Draft
Copilot wants to merge 6 commits intomasterfrom
copilot/fix-4b805f75-fa17-47f9-b05c-3df2fd774dcc
Draft

[WIP] Audit and Refactor Tests to Follow Pytest Conventions#3
Copilot wants to merge 6 commits intomasterfrom
copilot/fix-4b805f75-fa17-47f9-b05c-3df2fd774dcc

Conversation

Copy link

Copilot AI commented May 25, 2025

  • Analyze test files to understand current structure and dependencies
  • Develop refactoring strategy for each file type
  • Refactor qatrack/attachments/tests/test_models.py
    • Convert TestCase class to function-based tests
    • Add appropriate pytest markers (e.g., @pytest.mark.django_db)
    • Implement fixtures for common setup if needed
  • Refactor qatrack/qa/tests/test_utils.py
    • Convert TestUtils class to function-based tests
    • Convert TestImportExport class to fixture-based tests
    • Convert TestFormatQCValue class to function-based tests
  • Refactor qatrack/qa/tests/test_tags.py
    • Convert TestTags class to fixture-based function tests
    • Convert TestRefTolSpan class to function-based tests
    • Convert TestToleranceForReference class to function-based tests
    • Convert TestAsQCWindow class to function-based tests with fixtures
  • Refactor qatrack/reports/tests/test_qc.py
    • Convert TestCase classes to pytest-style tests
    • Organize tests by report type
    • Add descriptive docstrings to tests
    • Ensure appropriate pytest markers are applied
  • Refactor qatrack/reports/tests/test_service_log.py
    • Convert 6 TestCase classes to function-based tests
    • Add docstrings to improve readability
    • Group tests by report type for better organization
    • Add appropriate pytest markers
  • Refactor qatrack/notifications/qccompleted/test_qcc.py
    • Convert TestQCCompletedNoticeAdmin to fixture-based functions
    • Convert TestQCCompletedEmails to fixture-based functions
    • Convert TestQCCompletedNoticeModel to a simple function
    • Add descriptive docstrings to all tests
  • Refactor qatrack/notifications/service_log_scheduling/test_sls.py
    • Convert TestServiceEventSchedulingAdmin to fixture-based functions
    • Convert TestServiceEventSchedulingModel to fixture-based functions
    • Convert TestServiceEventSchedulingEmails to fixture-based functions
    • Use pytest markers for database access
  • Test all refactored modules to ensure functionality is preserved
  • Document common pytest fixtures created for reuse

I've completed refactoring the notification tests to follow pytest conventions. The main changes in this commit:

  1. In qatrack/notifications/qccompleted/test_qcc.py:

    • Converted three TestCase classes to function-based tests
    • Created fixtures for admin site, admin client, admin URLs, and email setup
    • Added docstrings to improve readability
    • Added appropriate pytest markers for database access
    • Ensured mail outbox is cleared between tests
  2. In qatrack/notifications/service_log_scheduling/test_sls.py:

    • Converted three TestCase classes to function-based tests
    • Created fixtures for admin site, model setup, and email setup
    • Added docstrings to all tests
    • Added pytest markers for database access
    • Preserved all test logic while making the code more maintainable

These changes complete the conversion of all specified test files to pytest conventions, focusing on:

  • Using fixtures instead of setUp methods
  • Using function-based tests instead of class-based tests
  • Using plain assert statements
  • Adding proper docstrings
  • Adding appropriate pytest markers
  • Maintaining test coverage and functionality

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits May 25, 2025 18:43
Co-authored-by: crcrewso <6089951+crcrewso@users.noreply.github.com>
Co-authored-by: crcrewso <6089951+crcrewso@users.noreply.github.com>
… pytest conventions

Co-authored-by: crcrewso <6089951+crcrewso@users.noreply.github.com>
Co-authored-by: crcrewso <6089951+crcrewso@users.noreply.github.com>
Co-authored-by: crcrewso <6089951+crcrewso@users.noreply.github.com>
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

Comments