@@ -0,0 +1,1389 @@
+#! /usr/bin/env python%0A%0Aimport unittest%0A%0Afrom redcap import Query, QueryGroup%0A%0Aclass QueryTests(unittest.TestCase):%0A    %22%22%22 Query Test Cases %22%22%22%0A    %0A    def setUp(self):%0A        self.data = %5B%7B'id':str(i), 'age':a, 'score':s%7D for i, a, s in %0A                        zip(range(1,6), range(12, 2, -2), range(10, 60, 10))%5D%0A    %0A    def tearDown(self):%0A        del self.data%0A        %0A    def test_bad_comp(self):%0A        bad_cmp = %7B'ze':'12'%7D%0A        bad_cmp_field = 'subjage'%0A        with self.assertRaises(ValueError):%0A            Query('subjage', %7B'ze':'12'%7D)%0A            %0A    def test_good_comp(self):%0A        good_cmp = %7B'le':10, 'lt':10, 'gt':1, 'ge':1, 'ne':5, 'eq':6%7D%0A        field = 'score'%0A        q = Query(field, good_cmp)%0A        self.assertIsInstance(q, Query)%0A        %0A    def test_filter(self):%0A        q = Query('age', %7B'gt':8%7D, 'number')%0A        self.assertEqual(len(q.filter(self.data, 'id')), 2)%0A        %0A    def test_groupfilter_and(self):%0A        q1 = Query('age', %7B'ge':5%7D)%0A        q2 = Query('score', %7B'lt':40%7D)%0A        q = QueryGroup(q1)%0A        q.add_query(q2, 'AND')%0A        self.assertEqual(len(q.filter(self.data, 'id')), 3)%0A        %0A    def test_groupfilter_or(self):%0A        q1 = Query('age', %7B'ge':5%7D)%0A        q2 = Query('score', %7B'lt':70%7D)%0A        q = QueryGroup(q1)%0A        q.add_query(q2, 'OR')%0A        self.assertEqual(len(q.filter(self.data, 'id')), 5)    

add query tests