コード例 #1
0
ファイル: tag.py プロジェクト: MattThurling/bugsquasher
def store(name):
    """
    Creates a new tag
    :param name: str
    """
    query = "INSERT INTO tags (name) VALUES (?)"
    params = (name, )
    db.run_statement(query, params, mode='write')
コード例 #2
0
def attach(test_name, plan_name):
    """
    Adds an existing test to an existing plan
    :param name: str
    """
    query = (
        "INSERT INTO test_plan (test_id, plan_id)"
        "VALUES ((SELECT id FROM tests WHERE name=?), (SELECT id FROM plans where name=?))"
    )
    params = (test_name, plan_name)
    db.run_statement(query, params, mode='write')
コード例 #3
0
ファイル: tag.py プロジェクト: MattThurling/bugsquasher
def attach(test_name, tag_name):
    """
    Attaches an existing tag to an existing test
    :param test_name:
    :param tag_name:
    :return:
    """
    query = (
        "INSERT INTO test_tag (test_id, tag_id)"
        "VALUES ((SELECT id FROM tests WHERE name=?), (SELECT id FROM tags where name=?))"
    )
    params = (test_name, tag_name)
    db.run_statement(query, params, mode='write')
コード例 #4
0
def get(plan='', name='', tag=''):
    """
    Gets a list of tests according to user's specified options
    :param plan: name of a test plan
    :param name: name of an individual test
    :param tag: single tag or list of tags
    :return: list of tuples
    """
    query = "SELECT tests.id, tests.name from tests"
    clause = ""
    params = ()
    if plan:
        clause = " JOIN test_plan ON tests.id = test_id JOIN plans ON plans.id = plan_id WHERE plans.name=?"
        params = (plan, )
    elif name:
        clause = " WHERE name=?"
        params = (name, )
    elif tag:
        # There may be a more elegant way of handling lists of tags!
        tlist = tag.split(',')
        tstring = "("
        for t in tlist:
            tstring += "'" + t + "',"
        tstring = tstring[:-1] + ")"

        query = ("SELECT s.id, s.name FROM "
                 "(SELECT * FROM tests JOIN test_tag on tests.id = test_id "
                 "JOIN tags on tags.id = tag_id WHERE tags.name IN ")

        query = query + tstring + ") as s GROUP BY s.name HAVING COUNT(s.name)=?"

        params = (len(tlist), )
    return db.run_statement(query + clause, params)
コード例 #5
0
ファイル: tag.py プロジェクト: MattThurling/bugsquasher
def get(name=''):
    query = 'SELECT * from tags'
    clause = ''
    params = ()
    if name:
        clause = ' WHERE name = ?'
        params = (name, )
    return db.run_statement(query + clause, params)
コード例 #6
0
def get(name=''):
    query = 'SELECT * from plans'
    clause = ''
    params = ()
    if (name):
        clause = ' WHERE name = ?'
        params = name

    return db.run_statement(query + clause, params)
コード例 #7
0
def plans(test_id):
    """
    Returns the plans associated with a particular test
    :param test_id: int id of the test
    :return: list of tuples
    """
    query = "SELECT plans.name from plans"
    clause = " JOIN test_plan ON plans.id = plan_id JOIN tests ON tests.id = test_id WHERE tests.id=?"
    params = (test_id, )

    return db.run_statement(query + clause, params)
コード例 #8
0
def tags(test_id):
    """
    Returns the tags associated with a particular test
    :param test_id: int id of the test
    :return: list of tuples
    """
    query = "SELECT tags.name from tags"
    clause = " JOIN test_tag ON tags.id = tag_id JOIN tests ON tests.id = test_id WHERE tests.id=?"
    params = (test_id, )

    return db.run_statement(query + clause, params)