예제 #1
0
def get_tags(request, values):
    """
    Description:  Get the list of tags.

    Params:      $values - Hash: keys must match valid search fields.
        +------------------------------------------------------------+
        |                   tag Search Parameters                    |
        +------------------------------------------------------------+
        | Key                     | Valid Values                     |
        | ids                     | List of Integer                  |
        | names                   | List of String                   |
        +------------------------------------------------------------+

    Returns:     Array: An array of tag object hashes.

    Example:

    >>> values= {'ids': [121, 123]}
    >>> Tag.get_tags(values)
    """
    if values.get('ids'):
        query = {'id__in': values.get('ids')}
        return TestTag.to_xmlrpc(query)
    elif values.get('names'):
        query = {'name__in': values.get('names')}
        return TestTag.to_xmlrpc(query)
    else:
        raise ValueError('Must specify ids or names at least.')
예제 #2
0
파일: tag.py 프로젝트: zumbi/Nitrate
def get_tags(request, values):
    """Get tags by ID or name.

    :param dict values: a mapping containing these criteria.

        * ids: (list[int]) list of tag IDs.
        * names: (list[str]) list of names.

    :return: a list of mappings of :class:`TestTag`.
    :rtype: list

    Example::

        >>> Tag.get_tags({'ids': [121, 123]})
    """
    if not isinstance(values, dict):
        raise TypeError('Argument values must be an dictionary.')
    if values.get('ids'):
        query = {'id__in': values.get('ids')}
        return TestTag.to_xmlrpc(query)
    elif values.get('names'):
        query = {'name__in': values.get('names')}
        return TestTag.to_xmlrpc(query)
    else:
        raise ValueError('Must specify ids or names at least.')
예제 #3
0
def get(request, run_id):
    """Used to load an existing test run from the database.

    :param int run_id: test run ID.
    :return: a mapping representing found :class:`TestRun`.
    :rtype: dict

    Example::

        >>> TestRun.get(1)
    """
    try:
        tr = TestRun.objects.get(run_id=run_id)
    except TestRun.DoesNotExist as error:
        return error
    response = tr.serialize()
    # get the xmlrpc tags
    tag_ids = tr.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    tags = TestTag.to_xmlrpc(query)
    # cut 'id' attribute off, only leave 'name' here
    tags_without_id = map(lambda x: x["name"], tags)
    # replace tag_id list in the serialize return data
    response["tag"] = tags_without_id
    return response
예제 #4
0
파일: testrun.py 프로젝트: sugus86/Nitrate
def get(request, run_id):
    """Used to load an existing test run from the database.

    :param int run_id: test run ID.
    :return: a mapping representing found :class:`TestRun`.
    :rtype: dict

    Example::

        TestRun.get(1)
    """
    try:
        tr = TestRun.objects.get(run_id=run_id)
    except TestRun.DoesNotExist as error:
        return error
    response = tr.serialize()
    # get the xmlrpc tags
    tag_ids = tr.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    tags = TestTag.to_xmlrpc(query)
    # cut 'id' attribute off, only leave 'name' here
    tags_without_id = [tag['name'] for tag in tags]
    # replace tag_id list in the serialize return data
    response["tag"] = tags_without_id
    return response
예제 #5
0
def get(run_id):
    """
    Description: Used to load an existing test run from the database.

    Params:      $run_id - Integer: An integer representing the ID of the run
                                    in the database

    Returns:     Hash: A blessed TestRun object hash

    Example:
    >>> TestRun.get(1193)
    """
    try:
        tr = TestRun.objects.get(run_id=run_id)
    except TestRun.DoesNotExist as error:
        return error
    response = tr.serialize()
    # get the xmlrpc tags
    tag_ids = tr.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    tags = TestTag.to_xmlrpc(query)
    # cut 'id' attribute off, only leave 'name' here
    tags_without_id = [x["name"] for x in tags]
    # replace tag_id list in the serialize return data
    response["tag"] = tags_without_id
    return response
예제 #6
0
def get(request, case_id):
    """
    Description: Used to load an existing test case from the database.

    Params:      $id - Integer/String: An integer representing the ID in the database

    Returns:     A blessed TestCase object Hash

    Example:
    >>> TestCase.get(1193)
    """
    try:
        tc = TestCase.objects.get(case_id=case_id)
    except:
        raise

    tc_latest_text = tc.latest_text().serialize()

    response = tc.serialize()
    response['text'] = tc_latest_text
    #get the xmlrpc tags
    tag_ids = tc.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    tags = TestTag.to_xmlrpc(query)
    #cut 'id' attribute off, only leave 'name' here
    tags_without_id = map(lambda x: x["name"], tags)
    #replace tag_id list in the serialize return data
    response["tag"] = tags_without_id
    return response
예제 #7
0
def get(request, case_id):
    """Used to load an existing test case from the database.

    :param case_id: case ID.
    :type case_id: int or str
    :return: a mappings representing found test case.
    :rtype: dict

    Example::

        >>> TestCase.get(1)
    """
    tc = TestCase.objects.get(case_id=case_id)

    tc_latest_text = tc.latest_text().serialize()

    response = tc.serialize()
    response['text'] = tc_latest_text
    # get the xmlrpc tags
    tag_ids = tc.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    tags = TestTag.to_xmlrpc(query)
    # cut 'id' attribute off, only leave 'name' here
    tags_without_id = map(lambda x: x["name"], tags)
    # replace tag_id list in the serialize return data
    response["tag"] = tags_without_id
    return response
예제 #8
0
파일: testplan.py 프로젝트: MrSenko/Nitrate
def get(request, plan_id):
    """
    Description: Used to load an existing test plan from the database.

    Params:      $id - Integer/String: An integer representing the ID of this plan in the database

    Returns:     Hash: A blessed TestPlan object hash

    Example:
    >>> TestPlan.get(137)
    """
    tp = TestPlan.objects.get(plan_id=plan_id)
    response = tp.serialize()

    # This is for backward-compatibility. Actually, this is not a good way to
    # add this extra field. But, now that's it.
    response['default_product_version'] = response['product_version']

    # get the xmlrpc tags
    tag_ids = tp.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    tags = TestTag.to_xmlrpc(query)
    # cut 'id' attribute off, only leave 'name' here
    tags_without_id = map(lambda x: x["name"], tags)
    # replace tag_id list in the serialize return data
    response["tag"] = tags_without_id
    return response
예제 #9
0
파일: testplan.py 프로젝트: jetlyb/Kiwi
def get(plan_id):
    """
    Description: Used to load an existing test plan from the database.

    Params:      $id - Integer/String: An integer representing the ID of this plan in the database

    Returns:     Hash: A blessed TestPlan object hash

    Example:
    >>> TestPlan.get(137)
    """
    tp = TestPlan.objects.get(plan_id=plan_id)
    response = tp.serialize()

    # This is for backward-compatibility. Actually, this is not a good way to
    # add this extra field. But, now that's it.
    response['default_product_version'] = response['product_version']

    # get the xmlrpc tags
    tag_ids = tp.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    tags = TestTag.to_xmlrpc(query)
    # cut 'id' attribute off, only leave 'name' here
    tags_without_id = [x["name"] for x in tags]
    # replace tag_id list in the serialize return data
    response["tag"] = tags_without_id
    return response
예제 #10
0
def get(request, case_id):
    """Used to load an existing test case from the database.

    :param case_id: case ID.
    :type case_id: int or str
    :return: a mappings representing found test case.
    :rtype: dict

    Example::

        TestCase.get(1)
    """
    tc = TestCase.objects.get(case_id=case_id)

    tc_latest_text = tc.latest_text().serialize()

    response = tc.serialize()
    response['text'] = tc_latest_text
    # get the xmlrpc tags
    tag_ids = tc.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    tags = TestTag.to_xmlrpc(query)
    # cut 'id' attribute off, only leave 'name' here
    tags_without_id = [tag['name'] for tag in tags]
    # replace tag_id list in the serialize return data
    response["tag"] = tags_without_id
    return response
예제 #11
0
def get(request, plan_id):
    """Used to load an existing test plan from the database.

    :param int plan_id: plan ID.
    :return: a mapping of found :class:`TestPlan`.
    :rtype: dict

    Example::

        >>> TestPlan.get(1)
    """
    tp = TestPlan.objects.get(plan_id=plan_id)
    response = tp.serialize()

    # This is for backward-compatibility. Actually, this is not a good way to
    # add this extra field. But, now that's it.
    response['default_product_version'] = response['product_version']

    # get the xmlrpc tags
    tag_ids = tp.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    tags = TestTag.to_xmlrpc(query)
    # cut 'id' attribute off, only leave 'name' here
    tags_without_id = map(lambda x: x["name"], tags)
    # replace tag_id list in the serialize return data
    response["tag"] = tags_without_id
    return response
예제 #12
0
def get(request, plan_id):
    """Used to load an existing test plan from the database.

    :param int plan_id: plan ID.
    :return: a mapping of found :class:`TestPlan`.
    :rtype: dict

    Example::

        TestPlan.get(1)
    """
    tp = TestPlan.objects.get(plan_id=plan_id)
    response = tp.serialize()

    # This is for backward-compatibility. Actually, this is not a good way to
    # add this extra field. But, now that's it.
    response['default_product_version'] = response['product_version']

    # get the xmlrpc tags
    tag_ids = tp.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    tags = TestTag.to_xmlrpc(query)
    # cut 'id' attribute off, only leave 'name' here
    tags_without_id = [tag['name'] for tag in tags]
    # replace tag_id list in the serialize return data
    response["tag"] = tags_without_id
    return response
예제 #13
0
def filter(query):
    """
    .. function:: XML-RPC Tag.filter(query)

        Search and return a list of tags

        :param query: Field lookups for :class:`tcms.management.models.TestTag`
        :type query: dict
        :return: Serialized list of :class:`tcms.management.models.TestTag` objects
        :rtype: list(dict)
    """
    return TestTag.to_xmlrpc(query)
예제 #14
0
def get_tags(request, plan_id):
    """Get the list of tags attached to this plan.

    :param int plan_id: plan ID.
    :return: list of mappings of found :class:`TestTag`.
    :rtype: list[dict]

    Example::

        >>> TestPlan.get_tags(1)
    """
    tp = TestPlan.objects.get(plan_id=plan_id)

    tag_ids = tp.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    return TestTag.to_xmlrpc(query)
예제 #15
0
def get_tags(request, run_id):
    """Get the list of tags attached to this run.

    :param int run_id: run ID.
    :return: a mapping representing found :class:`TestTag`.
    :rtype: dict

    Example::

        >>> TestRun.get_tags(1)
    """
    tr = TestRun.objects.get(run_id=run_id)

    tag_ids = tr.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    return TestTag.to_xmlrpc(query)
예제 #16
0
파일: testrun.py 프로젝트: sugus86/Nitrate
def get_tags(request, run_id):
    """Get the list of tags attached to this run.

    :param int run_id: run ID.
    :return: a mapping representing found :class:`TestTag`.
    :rtype: dict

    Example::

        TestRun.get_tags(1)
    """
    tr = TestRun.objects.get(run_id=run_id)

    tag_ids = tr.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    return TestTag.to_xmlrpc(query)
예제 #17
0
파일: testplan.py 프로젝트: jetlyb/Kiwi
def get_tags(plan_id):
    """
    Description: Get the list of tags attached to this plan.

    Params:      $plan_id - Integer An integer representing the ID of this plan in the database

    Returns:     Array: An array of tag object hashes.

    Example:
    >>> TestPlan.get_tags(137)
    """
    test_plan = TestPlan.objects.get(plan_id=plan_id)

    tag_ids = test_plan.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    return TestTag.to_xmlrpc(query)
예제 #18
0
def get_tags(request, plan_id):
    """Get the list of tags attached to this plan.

    :param int plan_id: plan ID.
    :return: list of mappings of found :class:`TestTag`.
    :rtype: list[dict]

    Example::

        TestPlan.get_tags(1)
    """
    tp = TestPlan.objects.get(plan_id=plan_id)

    tag_ids = tp.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    return TestTag.to_xmlrpc(query)
예제 #19
0
파일: testcase.py 프로젝트: jetlyb/Kiwi
def get_tags(case_id):
    """
    Description: Get the list of tags attached to this case.

    Params:      $case_id - Integer/String: An integer representing the ID in the database

    Returns:     Array: An array of tag object hashes.

    Example:
    >>> TestCase.get_tags(12345)
    """
    test_case = TestCase.objects.get(case_id=case_id)

    tag_ids = test_case.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    return TestTag.to_xmlrpc(query)
예제 #20
0
def get_tags(request, case_id):
    """Get the list of tags attached to this case.

    :param case_id: case ID.
    :type case_id: int or str
    :return: a list of mappings of :class:`TestTag`.
    :rtype: list[dict]

    Example::

        TestCase.get_tags(1)
    """
    tc = TestCase.objects.get(case_id=case_id)

    tag_ids = tc.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    return TestTag.to_xmlrpc(query)
예제 #21
0
def get_tags(request, case_id):
    """Get the list of tags attached to this case.

    :param case_id: case ID.
    :type case_id: int or str
    :return: a list of mappings of :class:`TestTag`.
    :rtype: list[dict]

    Example::

        >>> TestCase.get_tags(1)
    """
    tc = TestCase.objects.get(case_id=case_id)

    tag_ids = tc.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    return TestTag.to_xmlrpc(query)
예제 #22
0
파일: testplan.py 프로젝트: MrSenko/Nitrate
def get_tags(request, plan_id):
    """
    Description: Get the list of tags attached to this plan.

    Params:      $plan_id - Integer An integer representing the ID of this plan in the database

    Returns:     Array: An array of tag object hashes.

    Example:
    >>> TestPlan.get_tags(137)
    """
    try:
        tp = TestPlan.objects.get(plan_id=plan_id)
    except:
        raise

    tag_ids = tp.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    return TestTag.to_xmlrpc(query)
예제 #23
0
def get_tags(request, case_id):
    """
    Description: Get the list of tags attached to this case.

    Params:      $case_id - Integer/String: An integer representing the ID in the database

    Returns:     Array: An array of tag object hashes.

    Example:
    >>> TestCase.get_tags(12345)
    """
    try:
        tc = TestCase.objects.get(case_id=case_id)
    except:
        raise

    tag_ids = tc.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    return TestTag.to_xmlrpc(query)
예제 #24
0
def get_tags(request, run_id):
    """
    Description: Get the list of tags attached to this run.

    Params:      $run_id - Integer: An integer representing the ID of the run in the database

    Returns:     Array: An array of tag object hashes.

    Example:
    >>> TestRun.get_tags(1193)
    """
    try:
        tr = TestRun.objects.get(run_id=run_id)
    except:
        raise

    tag_ids = tr.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    return TestTag.to_xmlrpc(query)
예제 #25
0
def get_all_cases_tags(request, plan_id):
    """Get the list of tags attached to this plan's testcases.

    :param int plan_id: plan ID.
    :return: list of mappings of found :class:`TestTag`.
    :rtype: list[dict]

    Example::

        >>> TestPlan.get_all_cases_tags(137)
    """
    tp = TestPlan.objects.get(plan_id=plan_id)

    tcs = tp.case.all()
    tag_ids = []
    for tc in tcs.iterator():
        tag_ids.extend(tc.tag.values_list('id', flat=True))
    tag_ids = list(set(tag_ids))
    query = {'id__in': tag_ids}
    return TestTag.to_xmlrpc(query)
예제 #26
0
def get_all_cases_tags(request, plan_id):
    """Get the list of tags attached to this plan's testcases.

    :param int plan_id: plan ID.
    :return: list of mappings of found :class:`TestTag`.
    :rtype: list[dict]

    Example::

        TestPlan.get_all_cases_tags(137)
    """
    tp = TestPlan.objects.get(plan_id=plan_id)

    tcs = tp.case.all()
    tag_ids = []
    for tc in tcs.iterator():
        tag_ids.extend(tc.tag.values_list('id', flat=True))
    tag_ids = list(set(tag_ids))
    query = {'id__in': tag_ids}
    return TestTag.to_xmlrpc(query)
예제 #27
0
파일: testplan.py 프로젝트: jetlyb/Kiwi
def get_all_cases_tags(plan_id):
    """
    Description: Get the list of tags attached to this plan's testcases.

    Params:      $plan_id - Integer An integer representing the ID of this plan in the database

    Returns:     Array: An array of tag object hashes.

    Example:
    >>> TestPlan.get_all_cases_tags(137)
    """
    test_plan = TestPlan.objects.get(plan_id=plan_id)

    test_cases = test_plan.case.all()
    tag_ids = []
    for test_case in test_cases.iterator():
        tag_ids.extend(test_case.tag.values_list('id', flat=True))
    tag_ids = list(set(tag_ids))
    query = {'id__in': tag_ids}
    return TestTag.to_xmlrpc(query)
예제 #28
0
파일: testplan.py 프로젝트: MrSenko/Nitrate
def get_all_cases_tags(request, plan_id):
    """
    Description: Get the list of tags attached to this plan's testcases.

    Params:      $plan_id - Integer An integer representing the ID of this plan in the database

    Returns:     Array: An array of tag object hashes.

    Example:
    >>> TestPlan.get_all_cases_tags(137)
    """
    try:
        tp = TestPlan.objects.get(plan_id=plan_id)
    except:
        raise

    tcs = tp.case.all()
    tag_ids = []
    for tc in tcs.iterator():
        tag_ids.extend(tc.tag.values_list('id', flat=True))
    tag_ids = list(set(tag_ids))
    query = {'id__in': tag_ids}
    return TestTag.to_xmlrpc(query)
예제 #29
0
파일: testrun.py 프로젝트: MrSenko/Nitrate
                                    in the database

    Returns:     Hash: A blessed TestRun object hash

    Example:
    >>> TestRun.get(1193)
    """
    try:
        tr = TestRun.objects.get(run_id=run_id)
    except TestRun.DoesNotExist, error:
        return error
    response = tr.serialize()
    # get the xmlrpc tags
    tag_ids = tr.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    tags = TestTag.to_xmlrpc(query)
    # cut 'id' attribute off, only leave 'name' here
    tags_without_id = map(lambda x: x["name"], tags)
    # replace tag_id list in the serialize return data
    response["tag"] = tags_without_id
    return response


@log_call(namespace=__xmlrpc_namespace__)
def get_bugs(request, run_ids):
    """
    *** FIXME: BUGGY IN SERIALISER - List can not be serialize. ***
    Description: Get the list of bugs attached to this run.

    Params:      $run_ids - Integer/Array/String: An integer representing the ID in the database
                                                  an array of integers or a comma separated list of integers.
예제 #30
0
                                    in the database

    Returns:     Hash: A blessed TestRun object hash

    Example:
    >>> TestRun.get(1193)
    """
    try:
        tr = TestRun.objects.get(run_id=run_id)
    except TestRun.DoesNotExist, error:
        return error
    response = tr.serialize()
    # get the xmlrpc tags
    tag_ids = tr.tag.values_list('id', flat=True)
    query = {'id__in': tag_ids}
    tags = TestTag.to_xmlrpc(query)
    # cut 'id' attribute off, only leave 'name' here
    tags_without_id = map(lambda x: x["name"], tags)
    # replace tag_id list in the serialize return data
    response["tag"] = tags_without_id
    return response


@log_call(namespace=__xmlrpc_namespace__)
def get_bugs(request, run_ids):
    """
    *** FIXME: BUGGY IN SERIALISER - List can not be serialize. ***
    Description: Get the list of bugs attached to this run.

    Params:      $run_ids - Integer/Array/String: An integer representing the ID in the database
                                                  an array of integers or a comma separated list of integers.