Commit caea47f1 authored by Romain Courteaud's avatar Romain Courteaud

MORE TEST

parent 8bd2b9cc
......@@ -56,6 +56,8 @@ class UrlCheckerBotTestCase(unittest.TestCase):
mock_query.return_value = [MockAnswer("1.2.3.4")]
bot.iterateLoop()
assert mock_query.call_count == 1
assert bot._db.Status.select().count() == 1
assert bot._db.Status.get().text == "loop"
......@@ -80,15 +82,19 @@ class UrlCheckerBotTestCase(unittest.TestCase):
"urlchecker_dns.dns.resolver.Resolver.query"
) as mock_query, mock.patch(
"urlchecker_network.socket.socket"
), mock.patch(
) as mock_socket, mock.patch(
"urlchecker_http.request"
):
) as mock_request:
mock_get_default_resolver.return_value = resolver
mock_query.return_value = [MockAnswer("1.2.3.4")]
bot.iterateLoop()
assert mock_query.call_count == 2
assert mock_socket.call_count == 2
assert mock_request.call_count == 2
checkNetworkChange(
bot, [(resolver_ip, 53), ("1.2.3.4", 80), ("1.2.3.4", 443)]
)
......@@ -120,14 +126,18 @@ class UrlCheckerBotTestCase(unittest.TestCase):
"urlchecker_dns.dns.resolver.Resolver.query"
) as mock_query, mock.patch(
"urlchecker_network.socket.socket"
), mock.patch(
) as mock_socket, mock.patch(
"urlchecker_http.request"
):
) as mock_request:
mock_query.return_value = [MockAnswer("1.2.3.4")]
bot.iterateLoop()
assert mock_query.call_count == 4
assert mock_socket.call_count == 2
assert mock_request.call_count == 2
checkNetworkChange(
bot,
[
......@@ -168,14 +178,18 @@ class UrlCheckerBotTestCase(unittest.TestCase):
"urlchecker_dns.dns.resolver.Resolver.query"
) as mock_query, mock.patch(
"urlchecker_network.socket.socket"
), mock.patch(
) as mock_socket, mock.patch(
"urlchecker_http.request"
):
) as mock_request:
mock_query.return_value = [MockAnswer("1.2.3.4")]
bot.iterateLoop()
assert mock_query.call_count == 3
assert mock_socket.call_count == 2
assert mock_request.call_count == 4
checkNetworkChange(
bot, [(resolver_ip, 53), ("1.2.3.4", 80), ("1.2.3.4", 443)]
)
......@@ -209,9 +223,9 @@ class UrlCheckerBotTestCase(unittest.TestCase):
"urlchecker_dns.dns.resolver.Resolver.query"
) as mock_query, mock.patch(
"urlchecker_network.socket.socket"
), mock.patch(
) as mock_socket, mock.patch(
"urlchecker_http.request"
):
) as mock_request:
mock_query.return_value = [
MockAnswer("1.2.3.4"),
......@@ -220,6 +234,10 @@ class UrlCheckerBotTestCase(unittest.TestCase):
bot.iterateLoop()
assert mock_query.call_count == 2
assert mock_socket.call_count == 4
assert mock_request.call_count == 4
checkNetworkChange(
bot,
[
......@@ -261,14 +279,18 @@ class UrlCheckerBotTestCase(unittest.TestCase):
"urlchecker_dns.dns.resolver.Resolver.query"
) as mock_query, mock.patch(
"urlchecker_network.socket.socket"
), mock.patch(
) as mock_socket, mock.patch(
"urlchecker_http.request"
):
) as mock_request:
mock_query.return_value = [MockAnswer("1.2.3.4")]
bot.iterateLoop()
assert mock_query.call_count == 3
assert mock_socket.call_count == 2
assert mock_request.call_count == 4
checkNetworkChange(
bot, [(resolver_ip, 53), ("1.2.3.4", 80), ("1.2.3.4", 443)]
)
......@@ -302,13 +324,16 @@ class UrlCheckerBotTestCase(unittest.TestCase):
"urlchecker_dns.dns.resolver.Resolver.query"
) as mock_query, mock.patch(
"urlchecker_network.socket.socket"
), mock.patch(
) as mock_socket, mock.patch(
"urlchecker_http.request"
):
) as mock_request:
mock_query.return_value = [MockAnswer("1.2.3.4")]
bot.iterateLoop()
assert mock_query.call_count == 2
assert mock_socket.call_count == 2
assert mock_request.call_count == 3
checkNetworkChange(
bot, [(resolver_ip, 53), ("1.2.3.4", 80), ("1.2.3.4", 443)]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment