Exemple #1
0
    def test_works_onerow_noextras(self):
        self.cur.fetchall.return_value = [[sentinel.uniqueid]]

        results = group_manager._process_query(self.db_conn, self.query)

        self.assertEqual(len(results), 1)
        self.assertEqual(len(results[0].keys()), 1)
        self.assertEqual(results[0]['uniqueid'], sentinel.uniqueid)
Exemple #2
0
    def test_blows_up_with_bad_extras(self):
        indiv_array = [[sentinel.uniqueid, sentinel.field1, sentinel.field2]]
        self.cur.fetchall.return_value = indiv_array
        
        self.extras.append('field3')

        with self.assertRaises(IndexError):
            results = group_manager._process_query(self.db_conn, 
                                                   self.query, 
                                                   self.extras)
Exemple #3
0
    def test_works_onerow_extras(self):
        indiv_array = [[sentinel.uniqueid, sentinel.field1, sentinel.field2]]
        self.cur.fetchall.return_value = indiv_array

        results = group_manager._process_query(self.db_conn, self.query, self.extras)
        self.assertEqual(len(results), 1)
        self.assertEqual(len(results[0]), 3)
        
        self.assertIs(results[0]['field1'], sentinel.field1)
        self.assertIs(results[0]['field2'], sentinel.field2)
Exemple #4
0
    def test_works_multirows_noextras(self):
        id_array = [[sentinel.uniqueid1],
                    [sentinel.uniqueid2],
                    [sentinel.uniqueid3]]
        self.cur.fetchall.return_value = id_array

        results = group_manager._process_query(self.db_conn, self.query)

        self.assertEqual(len(results), 3)
        self.assertEqual(len(results[0].keys()), 1)

        for i in xrange(0,3):
            self.assertIs(results[i]['uniqueid'], id_array[i][0])
Exemple #5
0
    def test_works_multirows_extras(self):
        test_array = [[sentinel.uniqueid1, sentinel.field1_1, sentinel.field2_1],
                      [sentinel.uniqueid2, sentinel.field1_2, sentinel.field2_2],
                      [sentinel.uniqueid3, sentinel.field1_3, sentinel.field2_3]]

        self.cur.fetchall.return_value = test_array

        results = group_manager._process_query(self.db_conn, self.query, self.extras)

        self.assertEqual(len(results),3)
        self.assertEqual(len(results[0]), 3)

        for i in xrange(0,3):
            self.assertIs(results[i]['uniqueid'], test_array[i][0])
            self.assertIs(results[i]['field1'], test_array[i][1])
            self.assertIs(results[i]['field2'], test_array[i][2])
Exemple #6
0
    def test_works_norows_extras(self):
        self.cur.fetchall.return_value = list()

        results = group_manager._process_query(self.db_conn, self.query, self.extras)

        self.assertEqual(len(results), 0)