def test_to_only_filter(self): c = self._db._conn.cursor() # 12-01-2016,19:34:16, filt = Filter(c, to_filter=datetime.datetime(2016, 1, 12, 19, 34, 16)) events = filt.select_events() raw_data = filt.select_raw_data() self.assertEqual(len(events), 3) self.assertEqual(len(raw_data), 4)
def test_no_filters(self): c = self._db._conn.cursor() filt = Filter(c, file_filter=None, date_filter=None, from_filter=None, to_filter=None) events = filt.select_events() self.assertEqual(len(events), 9)
def test_multiple_filters(self): c = self._db._conn.cursor() # 12-01-2016,19:34:16, filt = Filter(c, date_filter=datetime.date(2016, 1, 12), from_filter=datetime.datetime(2016, 1, 12, 19, 34, 16), to_filter=datetime.datetime(2016, 1, 13, 19, 34, 15)) events = filt.select_events() raw_data = filt.select_raw_data() self.assertEqual(len(events), 2) self.assertEqual(len(raw_data), 2)
def test_file_filter(self): c = self._db._conn.cursor() filt = Filter(c, file_filter=self._testfile.name) events = filt.select_events() raw_data = filt.select_raw_data() self.assertEqual(len(events), 9) self.assertEqual(len(raw_data), 10) del (filt) filt = Filter(c, file_filter='NOT AN EXISTING FILE') events = filt.select_events() raw_data = filt.select_raw_data() self.assertEqual(len(events), 0) self.assertEqual(len(raw_data), 0)
def test_date_filter(self): c = self._db._conn.cursor() filt = Filter(c, date_filter=datetime.date(2016, 1, 12)) events = filt.select_events() raw_data = filt.select_raw_data() self.assertEqual(len(events), 4) self.assertEqual(len(raw_data), 5) del(filt) filt = Filter(c, date_filter=datetime.date(2016, 1, 13)) events = filt.select_events() raw_data = filt.select_raw_data() self.assertEqual(len(events), 5) self.assertEqual(len(raw_data), 5) del(filt) filt = Filter(c, date_filter=datetime.date(2016, 1, 14)) events = filt.select_events() raw_data = filt.select_raw_data() self.assertEqual(len(events), 0) self.assertEqual(len(raw_data), 0)
def test_file_filter(self): c = self._db._conn.cursor() filt = Filter(c, file_filter=self._testfile.name) events = filt.select_events() raw_data = filt.select_raw_data() self.assertEqual(len(events), 9) self.assertEqual(len(raw_data), 10) del(filt) filt = Filter(c, file_filter='NOT AN EXISTING FILE') events = filt.select_events() raw_data = filt.select_raw_data() self.assertEqual(len(events), 0) self.assertEqual(len(raw_data), 0)
def test_date_filter(self): c = self._db._conn.cursor() filt = Filter(c, date_filter=datetime.date(2016, 1, 12)) events = filt.select_events() raw_data = filt.select_raw_data() self.assertEqual(len(events), 4) self.assertEqual(len(raw_data), 5) del (filt) filt = Filter(c, date_filter=datetime.date(2016, 1, 13)) events = filt.select_events() raw_data = filt.select_raw_data() self.assertEqual(len(events), 5) self.assertEqual(len(raw_data), 5) del (filt) filt = Filter(c, date_filter=datetime.date(2016, 1, 14)) events = filt.select_events() raw_data = filt.select_raw_data() self.assertEqual(len(events), 0) self.assertEqual(len(raw_data), 0)