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
11840882
Commit
11840882
authored
Nov 29, 2019
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More tests
parent
74f2a5c6
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
329 additions
and
8 deletions
+329
-8
test_urlchecker_http.py
test_urlchecker_http.py
+2
-2
test_urlchecker_network.py
test_urlchecker_network.py
+317
-0
urlchecker_db.py
urlchecker_db.py
+5
-5
urlchecker_network.py
urlchecker_network.py
+5
-1
No files found.
test_urlchecker_http.py
View file @
11840882
...
@@ -8,7 +8,7 @@ import mock
...
@@ -8,7 +8,7 @@ import mock
import
peewee
import
peewee
class
UrlChecker
Status
TestCase
(
unittest
.
TestCase
):
class
UrlChecker
Http
TestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
db
=
LogDB
(
":memory:"
)
self
.
db
=
LogDB
(
":memory:"
)
self
.
db
.
createTables
()
self
.
db
.
createTables
()
...
@@ -306,7 +306,7 @@ class UrlCheckerStatusTestCase(unittest.TestCase):
...
@@ -306,7 +306,7 @@ class UrlCheckerStatusTestCase(unittest.TestCase):
def
suite
():
def
suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
UrlChecker
Status
TestCase
))
suite
.
addTest
(
unittest
.
makeSuite
(
UrlChecker
Http
TestCase
))
return
suite
return
suite
...
...
test_urlchecker_network.py
0 → 100644
View file @
11840882
This diff is collapsed.
Click to expand it.
urlchecker_db.py
View file @
11840882
...
@@ -43,12 +43,12 @@ class LogDB:
...
@@ -43,12 +43,12 @@ class LogDB:
# Store remote network status
# Store remote network status
class
NetworkChange
(
BaseModel
):
class
NetworkChange
(
BaseModel
):
status
=
peewee
.
ForeignKeyField
(
Status
)
status
=
peewee
.
ForeignKeyField
(
Status
)
ip
=
peewee
.
TextField
(
index
=
True
)
ip
=
peewee
.
TextField
()
transport
=
peewee
.
TextField
()
transport
=
peewee
.
TextField
()
port
=
peewee
.
IntegerField
()
port
=
peewee
.
IntegerField
()
state
=
peewee
.
TextField
()
state
=
peewee
.
TextField
()
#
class Meta:
class
Meta
:
#
primary_key = peewee.CompositeKey("status", "ip", "transport", "port")
primary_key
=
peewee
.
CompositeKey
(
"status"
,
"ip"
,
"transport"
,
"port"
)
class
DnsChange
(
BaseModel
):
class
DnsChange
(
BaseModel
):
status
=
peewee
.
ForeignKeyField
(
Status
)
status
=
peewee
.
ForeignKeyField
(
Status
)
...
@@ -59,8 +59,8 @@ class LogDB:
...
@@ -59,8 +59,8 @@ class LogDB:
class
HttpCodeChange
(
BaseModel
):
class
HttpCodeChange
(
BaseModel
):
status
=
peewee
.
ForeignKeyField
(
Status
)
status
=
peewee
.
ForeignKeyField
(
Status
)
ip
=
peewee
.
TextField
(
index
=
True
)
ip
=
peewee
.
TextField
()
url
=
peewee
.
TextField
(
index
=
True
)
url
=
peewee
.
TextField
()
status_code
=
peewee
.
IntegerField
()
status_code
=
peewee
.
IntegerField
()
class
Meta
:
class
Meta
:
primary_key
=
peewee
.
CompositeKey
(
"status"
,
"ip"
,
"url"
)
primary_key
=
peewee
.
CompositeKey
(
"status"
,
"ip"
,
"url"
)
...
...
urlchecker_network.py
View file @
11840882
...
@@ -30,7 +30,7 @@ def logNetwork(db, ip, transport, port, state, status_id):
...
@@ -30,7 +30,7 @@ def logNetwork(db, ip, transport, port, state, status_id):
port
=
port
,
port
=
port
,
state
=
state
,
state
=
state
,
)
)
return
previous_entry
.
id
return
previous_entry
.
status
def
isTcpPortOpen
(
db
,
ip
,
port
,
status_id
):
def
isTcpPortOpen
(
db
,
ip
,
port
,
status_id
):
...
@@ -53,6 +53,10 @@ def isTcpPortOpen(db, ip, port, status_id):
...
@@ -53,6 +53,10 @@ def isTcpPortOpen(db, ip, port, status_id):
# OSError: [Errno 101] Network is unreachable
# OSError: [Errno 101] Network is unreachable
state
=
"unreachable"
state
=
"unreachable"
else
:
else
:
sock
.
close
()
raise
except
:
sock
.
close
()
raise
raise
sock
.
close
()
sock
.
close
()
...
...
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