예제 #1
0
def filter_categories(request, query):
    """
    Description: Performs a search and returns the resulting list of categories.

    Params:      $query - Hash: keys must match valid search fields.

    +------------------------------------------------------------------+
    |              Component Search Parameters                         |
    +------------------------------------------------------------------+
    |        Key          |          Valid Values                      |
    | id                  | Integer: ID of product                     |
    | name                | String                                     |
    | product             | ForeignKey: Product                        |
    | description         | String                                     |
    +------------------------------------------------------------------+

    Returns:     Array: Matching categories are retuned in a list of hashes.

    Example:
    # Get all of categories named like 'libvirt'
    >>> Product.filter_categories({'name__icontains': 'regression'})
    # Get all of categories named in product 'Red Hat Enterprise Linux 5'
    >>> Product.filter_categories({'product__name': 'Red Hat Enterprise Linux 5'})
    """
    from nitrate.apps.testcases.models import TestCaseCategory
    return TestCaseCategory.to_xmlrpc(query)
예제 #2
0
def get_categories(request, product):
    """
    Description: Get the list of categories associated with this product.

    Params:      $product - Integer/String
                            Integer: product_id of the product in the Database
                            String: Product name

    Returns:     Array: Returns an array of Case Category objects.

    Example:
    # Get with product id
    >>> Product.get_categories(61)
    # Get with product name
    >>> Product.get_categories('Red Hat Enterprise Linux 5')
    """
    from nitrate.apps.testcases.models import TestCaseCategory
    p = pre_check_product(values = product)
    query = {'product': p}
    return TestCaseCategory.to_xmlrpc(query)