|
@@ -1,4 +1,4 @@
|
|
|
-import unittest
|
|
|
+import unittest, sqlite3
|
|
|
|
|
|
from definitions import ROOT_DIR
|
|
|
import Core.Controller as Ctrl
|
|
@@ -36,4 +36,21 @@ class UnitTestPyparsing(unittest.TestCase):
|
|
|
self.assertEqual("72.247.178.113", controller.statistics.stats_db.process_db_query(query2))
|
|
|
self.assertEqual(["72.247.178.67", "72.247.178.113"], controller.statistics.stats_db.process_db_query(query3))
|
|
|
self.assertEqual("10.0.2.15", controller.statistics.stats_db.process_db_query(query4))
|
|
|
- self.assertEqual(["10.0.2.15", "172.217.23.174"], controller.statistics.stats_db.process_db_query(query5))
|
|
|
+ self.assertEqual(["10.0.2.15", "172.217.23.174"], controller.statistics.stats_db.process_db_query(query5))
|
|
|
+
|
|
|
+ # too long query (stackoverflow)
|
|
|
+ with self.assertRaises(sqlite3.OperationalError):
|
|
|
+ query = "Select ipAddress from ip_statistics where pktsSent = "
|
|
|
+ i = 0
|
|
|
+ while (i < 15):
|
|
|
+ query += "(Select pktsSent from ip_statistics where pktsSent ="
|
|
|
+ i += 1
|
|
|
+ query += "5"
|
|
|
+ while (i > 0):
|
|
|
+ query += ")"
|
|
|
+ i -= 1
|
|
|
+ controller.statistics.stats_db.process_db_query(query)
|
|
|
+ # compare of tables with different dimension
|
|
|
+ with self.assertRaises(sqlite3.OperationalError):
|
|
|
+ controller.statistics.stats_db.process_db_query('Select ipAddress from ip_Statistics where pktsSent'
|
|
|
+ '= (Select * from ip_Statistics)')
|