Example #1
0
    def test_process_query(self):
        ''' test process_query '''
        qids.reset_atomic_qid_seen()
        qids.reset_full_qid_seen()
        query_result = qr.EqualityQueryResult(self.__query1, self.__result1,
                                              None, True)

        (atomic_entry, full_entry, full_to_atomic_entry, full_to_full_entry) = \
            query_result.process_query()
        full_entry[rdb.DBF_SELECTSTAR] = True
        self.assertEqual(atomic_entry, self.__query1_atomic_entry)
        self.assertEqual(full_entry, self.__query1_full_entry)
        self.assertEqual(full_to_atomic_entry,
                         self.__query1_full_to_atomic_entry)
        self.assertEqual(full_to_full_entry, {})

        # test again but pass in None for results
        qids.reset_atomic_qid_seen()
        qids.reset_full_qid_seen()
        query_result = qr.EqualityQueryResult(self.__query1, None, None, True)
        (atomic_entry, full_entry, full_to_atomic_entry, full_to_full_entry) = \
            query_result.process_query()
        full_entry[rdb.DBF_SELECTSTAR] = True
        self.assertEqual(atomic_entry, self.__query1_atomic_entry_no_matches)
        self.assertEqual(full_entry, self.__query1_full_entry_no_matches)
        self.assertEqual(full_to_atomic_entry,
                         self.__query1_full_to_atomic_entry)
        self.assertEqual(full_to_full_entry, {})
Example #2
0
 def test_init_method(self):
     ''' test __init__ method '''
     query_result = qr.EqualityQueryResult(self.__query1, self.__result1,
                                           None, True)
     self.assertEqual(query_result._query, self.__query1)
     self.assertEqual(query_result._result, self.__result1)
     self.assertEqual(query_result._top, True)
     self.assertEqual(query_result._db_object, None)
Example #3
0
 def test_write_query(self):
     ''' test write_query '''
     qids.reset_atomic_qid_seen()
     qids.reset_full_qid_seen()
     db_name = ':memory:'
     db_object = ta1_database.Ta1ResultsDB(db_name)
     query_result = qr.EqualityQueryResult(self.__query1, self.__result1,
                                           db_object, True)
     query_result.write_query()
     db_object.close()
Example #4
0
    def testQueryResult(self):
        qids.reset_full_qid_seen()
        count = 0
        for x in xrange(10):
            self.__query[qs.QRY_QID] = x
            query_result = qr.EqualityQueryResult(self.__query, self.__result,
                                                  None, True)

            (_, full_entry, _, _) = query_result.process_query()
            if full_entry[rdb.DBF_SELECTSTAR]:
                count += 1
        self.assertEqual(count, 2)