def test_copy(self): e1 = EventExpression('request', ['path', 'elapsed_ms']) e2 = e1.copy() self.assertEqual(e1, e2) e1 = e1.eq('path', '/') e3 = e1.copy() self.assertNotEqual(e1, e2) self.assertEqual(e1, e3) self.assertNotEqual(e2, e3)
def test_filter_chaining(self): e = EventExpression('test') e = e.eq('bar', 'baz') self.assertTrue(isinstance(e, EventExpression)) self.assertEqual(len(e.filters), 1) e = e.lt('fizz', 'bang') self.assertTrue(isinstance(e, EventExpression)) self.assertEqual(len(e.filters), 2) e = e.ge('foo', 4) self.assertTrue(isinstance(e, EventExpression)) self.assertEqual(len(e.filters), 3) self.assertEqual("%s" % e, 'test.eq(bar, "baz").lt(fizz, "bang").ge(foo, 4)')