Commit 03730196 authored by Romain Courteaud's avatar Romain Courteaud

FIX

parent caea47f1
......@@ -350,6 +350,42 @@ class UrlCheckerBotTestCase(unittest.TestCase):
],
)
def test_oneNameserverOneUrlNoIp(self):
resolver_ip = "127.0.0.1"
domain = "example.org"
bot = WebBot(
mapping={
"SQLITE": ":memory:",
"URL": "https://example2.org/foo",
"DNS": resolver_ip,
}
)
bot.initDB()
with mock.patch(
"urlchecker_dns.dns.resolver.Resolver.query"
) as mock_query, mock.patch(
"urlchecker_network.socket.socket"
) as mock_socket, mock.patch(
"urlchecker_http.request"
) as mock_request:
mock_query.side_effect = [[MockAnswer("1.2.3.4")], []]
bot.iterateLoop()
assert mock_query.call_count == 2
assert mock_socket.call_count == 0
assert mock_request.call_count == 0
checkNetworkChange(bot, [(resolver_ip, 53)])
checkDnsChange(
bot, [(resolver_ip, domain), (resolver_ip, "example2.org")]
)
checkHttpCodeChange(bot, [])
def suite():
suite = unittest.TestSuite()
......
......@@ -71,7 +71,9 @@ class WebBot:
# XXX put back orignal url list
for url in url_list:
if url not in url_dict:
url_dict[url] = url_dict[getRootUrl(url)]
root_url = getRootUrl(url)
if root_url in url_dict:
url_dict[url] = url_dict[root_url]
# Check HTTP Status
for url in url_dict:
......@@ -105,8 +107,8 @@ class WebBot:
self.stop()
except:
# XXX Put traceback in the log?
self.stop()
logStatus(self._db, "error")
self.stop()
raise
......
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