Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
url-checker
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
url-checker
Commits
03730196
Commit
03730196
authored
Dec 03, 2019
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FIX
parent
caea47f1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
2 deletions
+40
-2
test_urlchecker_bot.py
test_urlchecker_bot.py
+36
-0
urlchecker_bot.py
urlchecker_bot.py
+4
-2
No files found.
test_urlchecker_bot.py
View file @
03730196
...
@@ -350,6 +350,42 @@ class UrlCheckerBotTestCase(unittest.TestCase):
...
@@ -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
():
def
suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
...
...
urlchecker_bot.py
View file @
03730196
...
@@ -71,7 +71,9 @@ class WebBot:
...
@@ -71,7 +71,9 @@ class WebBot:
# XXX put back orignal url list
# XXX put back orignal url list
for
url
in
url_list
:
for
url
in
url_list
:
if
url
not
in
url_dict
:
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
# Check HTTP Status
for
url
in
url_dict
:
for
url
in
url_dict
:
...
@@ -105,8 +107,8 @@ class WebBot:
...
@@ -105,8 +107,8 @@ class WebBot:
self
.
stop
()
self
.
stop
()
except
:
except
:
# XXX Put traceback in the log?
# XXX Put traceback in the log?
self
.
stop
()
logStatus
(
self
.
_db
,
"error"
)
logStatus
(
self
.
_db
,
"error"
)
self
.
stop
()
raise
raise
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment