コード例 #1
0
 def set_delayed_test_to_done(self, guid_):
     """ This method updates the delayedTestData table in the DB
         to set the test with the selected guid to done.
         
         :param guid_: The guid that is provided by the test case. (Format: str(uuid.uuid4()))
         
         :returns: True (when no exceptions or errors occur)
     """
     db = DatabaseManager()
     query = """UPDATE delayedTestData
                SET done=TRUE
                WHERE guid=%(guid)s
                AND done=FALSE"""
     db.execute_query_and_close(query, {"guid":guid_})
     return True
コード例 #2
0
    def get_delayed_test_data(self, testcase_address, done=0):
        """ This method queries the delayedTestData table in the DB and
            then returns a list of rows with the matching parameters.
            
            :param testcase_address: The ID (address) of the test case.
            :param done: (0 for test not done or 1 for test done)

            :returns: A list of rows found with the matching testcase_address. None otherwise.
        """
        db = DatabaseManager()
        query = """SELECT guid,testcaseAddress,insertedAt,expectedResult,done
                   FROM delayedTestData
                   WHERE testcaseAddress=%(testcase_address)s
                   AND done=%(done)s"""
        data = db.fetchall_query_and_close(query, {"testcase_address":testcase_address,
                                           "done":done})
        if data:
            return data
        else:
            logging.debug("Could not find any rows in delayedTestData.")
            logging.debug("DB Query = " + query % {"testcase_address":testcase_address, "done":done})
            return []
コード例 #3
0
    def insert_delayed_test_data(self, guid_, testcase_address, expected_result, done=0, expires_at=DEFAULT_EXPIRATION):
        """ This method inserts rows into the delayedTestData table in the DB based on the
            given parameters where inserted_at (Date format) is automatically set in this method.
            
            :param guid_: The guid that is provided by the test case. (Format: str(uuid.uuid4()))
            :param testcase_address: The ID (address) of the test case.
            :param expected_result: The result string of persistent data that will be stored in the DB.
            :param done: (0 for test not done or 1 for test done)
            
            :returns: True (when no exceptions or errors occur)
        """
        inserted_at = int(time.time() * 1000)

        db = DatabaseManager()
        query = """INSERT INTO delayedTestData(guid,testcaseAddress,insertedAt,expectedResult,done,expiresAt)
                   VALUES (%(guid)s,%(testcaseAddress)s,%(inserted_at)s,%(expected_result)s,%(done)s,%(expires_at)s)"""

        db.execute_query_and_close(query, {"guid":guid_,
                                   "testcaseAddress":testcase_address,
                                   "inserted_at":inserted_at,
                                   "expected_result":expected_result,
                                   "done":done,
                                   "expires_at":inserted_at + expires_at})
        return True