Commit 11840882 authored by Romain Courteaud's avatar Romain Courteaud

More tests

parent 74f2a5c6
...@@ -8,7 +8,7 @@ import mock ...@@ -8,7 +8,7 @@ import mock
import peewee import peewee
class UrlCheckerStatusTestCase(unittest.TestCase): class UrlCheckerHttpTestCase(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(UrlCheckerStatusTestCase)) suite.addTest(unittest.makeSuite(UrlCheckerHttpTestCase))
return suite return suite
......
This diff is collapsed.
...@@ -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")
......
...@@ -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()
......
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