Commit 11840882 authored by Romain Courteaud's avatar Romain Courteaud

More tests

parent 74f2a5c6
......@@ -8,7 +8,7 @@ import mock
import peewee
class UrlCheckerStatusTestCase(unittest.TestCase):
class UrlCheckerHttpTestCase(unittest.TestCase):
def setUp(self):
self.db = LogDB(":memory:")
self.db.createTables()
......@@ -306,7 +306,7 @@ class UrlCheckerStatusTestCase(unittest.TestCase):
def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(UrlCheckerStatusTestCase))
suite.addTest(unittest.makeSuite(UrlCheckerHttpTestCase))
return suite
......
This diff is collapsed.
......@@ -43,12 +43,12 @@ class LogDB:
# Store remote network status
class NetworkChange(BaseModel):
status = peewee.ForeignKeyField(Status)
ip = peewee.TextField(index=True)
ip = peewee.TextField()
transport = peewee.TextField()
port = peewee.IntegerField()
state = peewee.TextField()
# class Meta:
# primary_key = peewee.CompositeKey("status", "ip", "transport", "port")
class Meta:
primary_key = peewee.CompositeKey("status", "ip", "transport", "port")
class DnsChange(BaseModel):
status = peewee.ForeignKeyField(Status)
......@@ -59,8 +59,8 @@ class LogDB:
class HttpCodeChange(BaseModel):
status = peewee.ForeignKeyField(Status)
ip = peewee.TextField(index=True)
url = peewee.TextField(index=True)
ip = peewee.TextField()
url = peewee.TextField()
status_code = peewee.IntegerField()
class Meta:
primary_key = peewee.CompositeKey("status", "ip", "url")
......
......@@ -30,7 +30,7 @@ def logNetwork(db, ip, transport, port, state, status_id):
port=port,
state=state,
)
return previous_entry.id
return previous_entry.status
def isTcpPortOpen(db, ip, port, status_id):
......@@ -53,6 +53,10 @@ def isTcpPortOpen(db, ip, port, status_id):
# OSError: [Errno 101] Network is unreachable
state = "unreachable"
else:
sock.close()
raise
except:
sock.close()
raise
sock.close()
......
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