Skip to content

Commit

Permalink
Increase coverage about DNS feature
Browse files Browse the repository at this point in the history
  • Loading branch information
pfreixes committed Apr 18, 2017
1 parent 91074ad commit 25f51ee
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions tests/test_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def test_release_close(loop):


@asyncio.coroutine
def test_tcp_connector_resolve_host_use_dns_cache(loop):
def test_tcp_connector_resolve_host(loop):
conn = aiohttp.TCPConnector(loop=loop, use_dns_cache=True)

res = yield from conn._resolve_host('localhost', 8080)
Expand All @@ -365,8 +365,12 @@ def test_tcp_connector_resolve_host_use_dns_cache(loop):


@asyncio.coroutine
def test_tcp_connector_resolve_host_twice_use_dns_cache(loop):
conn = aiohttp.TCPConnector(loop=loop, use_dns_cache=True)
def test_tcp_connector_dns_cache_not_expired(loop):
conn = aiohttp.TCPConnector(
loop=loop,
use_dns_cache=True,
ttl_dns_cache=10
)

res = yield from conn._resolve_host('localhost', 8080)
res2 = yield from conn._resolve_host('localhost', 8080)
Expand All @@ -375,33 +379,26 @@ def test_tcp_connector_resolve_host_twice_use_dns_cache(loop):


@asyncio.coroutine
def test_tcp_connector_resolve_host_twice_dns_cache_not_expired(loop):
def test_tcp_connector_dns_cache_forever(loop):
conn = aiohttp.TCPConnector(
loop=loop,
use_dns_cache=True,
ttl_dns_cache=60
ttl_dns_cache=None
)

res = yield from conn._resolve_host('localhost', 8080)
res2 = yield from conn._resolve_host('localhost', 8080)

assert res is res2


@asyncio.coroutine
def test_tcp_connector_resolve_host_twice_dns_cache_expired(loop):
conn = aiohttp.TCPConnector(
loop=loop,
use_dns_cache=True,
ttl_dns_cache=0.1
)
def test_tcp_connector_use_dns_cache_disabled(loop):
conn = aiohttp.TCPConnector(loop=loop, use_dns_cache=False)

res = yield from conn._resolve_host('localhost', 8080)
yield from asyncio.sleep(0.2, loop=loop)
res2 = yield from conn._resolve_host('localhost', 8080)

assert res is not res2
assert res == res2


def test_get_pop_empty_conns(loop):
Expand Down

0 comments on commit 25f51ee

Please sign in to comment.