{% extends "base_system.md.j2" %}

{% block role_target %}**async** `{{ function_name }}`{% endblock %}
{% block analysis_target %}async function{% endblock %}
{% block analysis_extra %}
4. What async-specific edge cases exist (concurrent execution, coroutine handling)?
5. What large-scale or throughput scenarios should be covered?
{% endblock %}

{% block categories %}
Then write tests organized into four categories:

**Basic tests** — Verify fundamental functionality under normal conditions. Test that the function returns expected values when awaited, and test basic async/await behavior.

**Edge tests** — Evaluate behavior under extreme or unusual conditions: empty inputs, boundary values, concurrent execution scenarios, exception handling in async context.

**Large-scale tests** — Assess performance and scalability with concurrent execution. Test multiple concurrent calls using `asyncio.gather()`. Use data structures up to 1000 elements and loops up to 1000 iterations.

**Throughput tests** — Measure performance under load and high-volume scenarios. Name these functions with `_throughput_` in the name (e.g., `test_function_throughput_high_load`). Test with varying loads (small, medium, large) and sustained execution patterns.
{% endblock %}

{% block mock_extras %}`AsyncMock`, {% endblock %}
{% block quality_extra %}
- Include concurrent execution tests using `asyncio.gather()` to assess async performance
- Test proper async/await patterns and coroutine handling
{% endblock %}

{% block async_rules_section %}
{% if is_xml %}<async_rules>{% else %}## Async-Specific Rules{% endif %}
- All test functions must use `async def` and be marked with `@pytest.mark.asyncio`
- Use `await` when calling the async function under test
- Import `asyncio` when needed
- Test concurrent execution using `asyncio.gather()` where appropriate
- Never create tests that intentionally timeout or hang. No `asyncio.wait_for()` with short timeouts expecting `TimeoutError`. No tests that rely on timing or delays.
- All throughput test functions must include `_throughput_` in their name
{% if is_xml %}</async_rules>{% endif %}
{% endblock %}

{% block method_call_detail %} with `await instance.method(...)`{% endblock %}
{% block test_signature %}async def test_...{% endblock %}
{% block critical_mock_extras %}AsyncMock, {% endblock %}
