core/tests/test_util/test_aiohttp.py

22 lines
584 B
Python
Raw Normal View History

"""Tests for our aiohttp mocker."""
import pytest
from .aiohttp import AiohttpClientMocker
async def test_matching_url():
"""Test we can match urls."""
mocker = AiohttpClientMocker()
2019-07-31 19:25:30 +00:00
mocker.get("http://example.com")
await mocker.match_request("get", "http://example.com/")
mocker.clear_requests()
with pytest.raises(AssertionError):
2019-07-31 19:25:30 +00:00
await mocker.match_request("get", "http://example.com/")
mocker.clear_requests()
2019-07-31 19:25:30 +00:00
mocker.get("http://example.com?a=1")
await mocker.match_request("get", "http://example.com/", params={"a": 1, "b": 2})