|
@@ -1,11 +1,9 @@
|
|
|
import unittest, sqlite3
|
|
|
|
|
|
-from definitions import ROOT_DIR
|
|
|
+import ID2TLib.TestLibrary as Lib
|
|
|
import Core.Controller as Ctrl
|
|
|
|
|
|
-pcap = ROOT_DIR + "/../resources/test/reference_1998.pcap"
|
|
|
-
|
|
|
-controller = Ctrl.Controller(pcap_file_path=pcap, do_extra_tests=False, non_verbose=False)
|
|
|
+controller = Ctrl.Controller(pcap_file_path=Lib.test_pcap, do_extra_tests=False, non_verbose=False)
|
|
|
controller.load_pcap_statistics(flag_write_file=False, flag_recalculate_stats=True, flag_print_statistics=False)
|
|
|
|
|
|
|
|
@@ -17,15 +15,15 @@ class UnitTestPyparsing(unittest.TestCase):
|
|
|
self.assertEqual(controller.statistics.stats_db.process_db_query(query),
|
|
|
controller.statistics.stats_db.process_db_query(query2))
|
|
|
|
|
|
- def test_paranthesis(self):
|
|
|
+ def test_parenthesis(self):
|
|
|
query = "Select (ipAddress) from (ip_Statistics) where (pktsSent) = (2 + (3))"
|
|
|
self.assertEqual("72.247.178.67", controller.statistics.stats_db.process_db_query(query))
|
|
|
|
|
|
- def test_noresult(self):
|
|
|
+ def test_noResult(self):
|
|
|
query = "Select ipAddress from ip_statistics where ipaddress = 'abc'"
|
|
|
self.assertEqual([], controller.statistics.stats_db.process_db_query(query))
|
|
|
|
|
|
- def test_severaloperator(self):
|
|
|
+ def test_severalOperator(self):
|
|
|
query1 = "Select ipAddress from ip_Statistics where pktsSent = '5'"
|
|
|
query2 = "Select ipAddress from ip_Statistics where pktsSent < '5'"
|
|
|
query3 = "Select ipAddress from ip_Statistics where pktsSent <= '5'"
|
|
@@ -38,18 +36,6 @@ class UnitTestPyparsing(unittest.TestCase):
|
|
|
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))
|
|
|
|
|
|
- # 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'
|