---
name: block-duplicate-fixtures
enabled: true
event: file
action: block
conditions:
  # Match test files EXCEPT root conftest.py (where global fixtures should be defined)
  # Uses negative lookahead to exclude tests/conftest.py but include:
  #   - tests/unit/conftest.py (sub-conftest can't override root)
  #   - tests/unit/test_foo.py (test files can't override root)
  - field: file_path
    operator: regex_match
    pattern: tests?/(?!conftest\.py$).+\.py$
  # Only block if redefining a specific root conftest.py fixture
  - field: new_text
    operator: regex_match
    pattern: "@pytest\\.fixture[^@]*\\ndef\\s+(mock_uow|crypto|meetings_dir|webhook_config|webhook_config_all_events|sample_datetime|calendar_settings|meeting_id|sample_meeting|recording_meeting|mock_grpc_context|mock_asr_engine|mock_optional_extras)\\s*\\("
---

🚫 **Test Quality Violation: Duplicate Fixture Definition**

Your edit redefines a **fixture that already exists in `tests/conftest.py`**.

**Detected fixture duplication attempt:**
The following fixtures are globally available from root `tests/conftest.py`:
- `mock_uow` - Mock UnitOfWork with all repositories
- `crypto` - AesGcmCryptoBox with in-memory keystore
- `meetings_dir` - Temporary meetings directory
- `webhook_config` - WebhookConfig for MEETING_COMPLETED
- `webhook_config_all_events` - WebhookConfig for all events
- `sample_datetime` - UTC datetime fixture
- `calendar_settings` - CalendarSettings for OAuth testing
- `meeting_id` - Test MeetingId
- `sample_meeting` - Sample Meeting entity
- `recording_meeting` - Meeting in RECORDING state
- `mock_grpc_context` - Mock gRPC ServicerContext
- `mock_asr_engine` - Mock ASR engine

**Why this is blocked:**
- Fixture duplication creates maintenance burden
- Inconsistent test behavior when fixtures diverge
- Violates DRY principle
- Cross-file fixture duplicates are flagged by `tests/quality/`

**What to do instead:**
1. **Use the existing fixture** from `tests/conftest.py`
2. **If you need variations**, create a new fixture with a different name
3. **If the global fixture is insufficient**, update root `tests/conftest.py`

**Allowed locations for new fixtures:**
- `tests/conftest.py` - Add global fixtures here (unrestricted)
- `tests/<subdir>/conftest.py` - Add scoped fixtures with unique names
- Any test file - Add test-specific fixtures with unique names

**Project reference:** See `tests/conftest.py` for all available fixtures.
