|
| 1 | +# TESTS SUITE |
| 2 | + |
| 3 | +## OVERVIEW |
| 4 | +Pytest-based test suite validating API integration, dual-mode (sync/async) operations, and error handling for all captcha services. |
| 5 | + |
| 6 | +## STRUCTURE |
| 7 | +``` |
| 8 | +tests/ |
| 9 | +├── conftest.py # BaseTest class, fixtures, test utilities |
| 10 | +├── test_*.py # Test modules (match source structure) |
| 11 | +└── files/ # Test assets (e.g., captcha_example.jpeg) |
| 12 | +``` |
| 13 | + |
| 14 | +## WHERE TO LOOK |
| 15 | +| Task | Location | Notes | |
| 16 | +|------|----------|-------| |
| 17 | +| **Base Test Class** | `tests/conftest.py` | `BaseTest` with utilities (`get_random_string`, `read_image`) | |
| 18 | +| **Fixtures** | `tests/conftest.py` | `delay_func` (1s), `delay_class` (2s) for rate limiting | |
| 19 | +| **Core Tests** | `tests/test_core.py` | Base logic, retries, enums, context managers | |
| 20 | +| **Service Tests** | `tests/test_*.py` | Per-service tests (recaptcha, cloudflare, datadome, etc.) | |
| 21 | +| **Instrument Tests** | `tests/test_instrument.py` | File processing, instruments | |
| 22 | +| **Pytest Config** | `pyproject.toml` | `asyncio_mode = "auto"`, testpaths | |
| 23 | + |
| 24 | +## CONVENTIONS |
| 25 | +- **Framework**: Pytest 7.0+ with `pytest-asyncio` (auto mode). |
| 26 | +- **Dual Testing**: Every sync test (`def test_*`) has async counterpart (`async def test_aio_*`). |
| 27 | +- **Parametrization**: Use `@pytest.mark.parametrize` for multiple captcha types in single test. |
| 28 | +- **Base Class**: All tests inherit from `BaseTest` for common utilities and rate limiting. |
| 29 | +- **Context Managers**: Test both `with` and `async with` patterns for resource cleanup. |
| 30 | +- **Rate Limiting**: Default delays (1s function, 2s class) to avoid API throttling. |
| 31 | +- **Error Testing**: Verify `errorId`, `errorCode`, and `solution=None` for invalid keys. |
0 commit comments