Esempio n. 1
0
 def test_filter_object(self):
     tdb = TrailDB('testtrail')
     obj = tdb.create_filter([[('field1', 'e'), ('field1', 'c')],
                              [('field3', 'y', True)]])
     events = list(tdb.trail(0, event_filter=obj))
     self.assertEqual(len(events), 1)
     self.assertEqual((events[0].field1, events[0].field2), ('e', '5'))
     events = list(tdb.trail(0, event_filter=obj))
     self.assertEqual(len(events), 1)
     self.assertEqual((events[0].field1, events[0].field2), ('e', '5'))
Esempio n. 2
0
 def test_filter_object(self):
     tdb = TrailDB('testtrail')
     obj = tdb.create_filter([[('field1', 'e'), ('field1', 'c')],
                              [('field3', 'y', True)]])
     events = list(tdb.trail(0, event_filter=obj))
     self.assertEqual(len(events), 1)
     self.assertEqual((events[0].field1, events[0].field2), ('e', '5'))
     events = list(tdb.trail(0, event_filter=obj))
     self.assertEqual(len(events), 1)
     self.assertEqual((events[0].field1, events[0].field2), ('e', '5'))
Esempio n. 3
0
 def test_negation(self):
     tdb = TrailDB('testtrail')
     events = list(tdb.trail(0, event_filter=[('field3', 'x', True)]))
     self.assertEqual(len(events), 1)
     self.assertEqual(
         (events[0].field1, events[0].field2, events[0].field3),
         ('c', '3', 'y'))
Esempio n. 4
0
 def test_simple_disjunction(self):
     tdb = TrailDB('testtrail')
     # test shorthand notation (not a list of lists)
     events = list(tdb.trail(0, event_filter=[('field1', 'a'), ('field2', '4')]))
     self.assertEqual(len(events), 2)
     self.assertEqual((events[0].field1, events[0].field2), ('a', '1'))
     self.assertEqual((events[1].field1, events[1].field2), ('d', '4'))
Esempio n. 5
0
 def test_simple_disjunction(self):
     tdb = TrailDB('testtrail')
     # test shorthand notation (not a list of lists)
     events = list(tdb.trail(0, event_filter=[('field1', 'a'), ('field2', '4')]))
     self.assertEqual(len(events), 2)
     self.assertEqual((events[0].field1, events[0].field2), ('a', '1'))
     self.assertEqual((events[1].field1, events[1].field2), ('d', '4'))
Esempio n. 6
0
 def test_conjunction(self):
     tdb = TrailDB('testtrail')
     events = list(
         tdb.trail(0,
                   event_filter=[[('field1', 'e'), ('field1', 'c')],
                                 [('field3', 'y', True)]]))
     self.assertEqual(len(events), 1)
     self.assertEqual((events[0].field1, events[0].field2), ('e', '5'))
Esempio n. 7
0
 def test_time_range(self):
     tdb = TrailDB('testtrail')
     events = list(tdb.trail(0,
                             event_filter=[[(2, 4)]],
                             parsetime=False))
     self.assertEqual(len(events), 2)
     self.assertEqual(events[0].time, 2L)
     self.assertEqual(events[1].time, 3L)
Esempio n. 8
0
    def test_trails(self):
        db = TrailDB('testtrail')
        self.assertEqual(1, db.num_trails)

        trail = db.trail(0)
        self.assertIsInstance(trail, TrailDBCursor)

        events = list(trail) # Force evaluation of generator
        self.assertEqual(3, len(events))
        for event in events:
            self.assertTrue(hasattr(event, 'time'))
            self.assertTrue(hasattr(event, 'field1'))
            self.assertTrue(hasattr(event, 'field2'))
Esempio n. 9
0
    def test_trails(self):
        db = TrailDB('testtrail')
        self.assertEqual(1, db.num_trails)

        trail = db.trail(0)
        self.assertIsInstance(trail, TrailDBCursor)

        events = list(trail)  # Force evaluation of generator
        self.assertEqual(3, len(events))
        for event in events:
            self.assertTrue(hasattr(event, 'time'))
            self.assertTrue(hasattr(event, 'field1'))
            self.assertTrue(hasattr(event, 'field2'))
Esempio n. 10
0
 def test_conjunction(self):
     tdb = TrailDB('testtrail')
     events = list(tdb.trail(0, event_filter=[[('field1', 'e'), ('field1', 'c')],
                                              [('field3', 'y', True)]]))
     self.assertEqual(len(events), 1)
     self.assertEqual((events[0].field1, events[0].field2), ('e', '5'))
Esempio n. 11
0
 def test_negation(self):
     tdb = TrailDB('testtrail')
     events = list(tdb.trail(0, event_filter=[('field3', 'x', True)]))
     self.assertEqual(len(events), 1)
     self.assertEqual((events[0].field1, events[0].field2, events[0].field3), ('c', '3', 'y'))