Esempio n. 1
0
def get_test_runs(request, plan_id):
    """
    Description: Get the list of runs in this plan.

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

    Returns:     Array: An array of test run object hashes.

    Example:
    >>> TestPlan.get_test_runs(plan_id)
    """
    from nitrate.apps.testruns.models import TestRun
    query = {'plan': plan_id}
    return TestRun.to_xmlrpc(query)
Esempio n. 2
0
def get_runs(request, build_id):
    """
    Description: Returns the list of runs that this Build is used in.

    Params:      $id -  Integer: Build ID.

    Returns:     Array: List of run object hashes.

    Example:
    >>> Build.get_runs(1234)
    """
    from nitrate.apps.testruns.models import TestRun

    tb = TestBuild.objects.get(build_id = build_id)
    query = {'build': tb}

    return TestRun.to_xmlrpc(query)
Esempio n. 3
0
def get_runs(request, product):
    """
    Description: Get the list of runs 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 Test Run objects.

    Example:
    # Get with product id
    >>> Product.get_runs(61)
    # Get with product name
    >>> Product.get_runs('Red Hat Enterprise Linux 5')
    """
    from nitrate.apps.testruns.models import TestRun
    p = pre_check_product(values = product)
    query = {'build__product': p}
    return TestRun.to_xmlrpc(query)
Esempio n. 4
0
def filter(request, values = {}):
    """
    Description: Performs a search and returns the resulting list of test runs.

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

        +--------------------------------------------------------+
        |                 Run Search Parameters                  |
        +--------------------------------------------------------+
        |        Key          |          Valid Values            |
        | build               | ForeignKey: Build                |
        | cc                  | ForeignKey: Auth.User            |
        | env_value           | ForeignKey: Environment Value    |
        | default_tester      | ForeignKey: Auth.User            |
        | run_id              | Integer                          |
        | manager             | ForeignKey: Auth.User            |
        | notes               | String                           |
        | plan                | ForeignKey: Test Plan            |
        | summary             | String                           |
        | tag                 | ForeignKey: Tag                  |
        | product_version     | String: Product version          |
        +--------------------------------------------------------+

    Returns:     Array: Matching test runs are retuned in a list of run object hashes.

    Example:
    # Get all of runs contain 'TCMS' in summary
    >>> TestRun.filter({'summary__icontain': 'TCMS'})
    # Get all of runs managed by xkuang
    >>> TestRun.filter({'manager__username': '******'})
    # Get all of runs the manager name starts with x
    >>> TestRun.filter({'manager__username__startswith': 'x'})
    # Get runs contain the case ID 12345, 23456, 34567
    >>> TestRun.filter({'case_run__case__case_id__in': [12345, 23456, 34567]})
    """
    return TestRun.to_xmlrpc(values)
Esempio n. 5
0
def update(request, run_ids, values):
    """
    Description: Updates the fields of the selected test run.

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

                 $values - Hash of keys matching TestRun fields and the new values
                           to set each field to. See params of TestRun.create for description
                 +-------------------+----------------+--------------------------+
                 | Field             | Type           | Description              |
                 +-------------------+----------------+--------------------------+
                 | plan              | Integer        | TestPlan.plan_id         |
                 | product           | Integer        | Product.id               |
                 | build             | Integer        | Build.id                 |
                 | errata_id         | Integer        | Errata.id                |
                 | manager           | Integer        | Auth.User.id             |
                 | default_tester    | Intege         | Auth.User.id             |
                 | summary           | String         |                          |
                 | estimated_time    | TimeDelta      | MM/DD/YYYY               |
                 | product_version   | Integer        |                          |
                 | plan_text_version | Integer        |                          |
                 | notes             | String         |                          |
                 | status            | Integer        | 0:RUNNING 1:FINISHED     |
                 +-------------------+----------------+ -------------------------+
    Returns:     Hash: The updated test run object.

    Example:
    # Update status to finished for run 1193 and 1194
    >>> TestRun.update([1193, 1194], {'status': 1})
    """
    from datetime import datetime
    from nitrate.core import forms
    from nitrate.apps.testruns.forms import XMLRPCUpdateRunForm

    if (values.get('product_version') and not values.get('product')):
        raise ValueError('Field "product" is required by product_version')

    form = XMLRPCUpdateRunForm(values)
    if values.get('product_version'):
        form.populate(product_id = values['product'])

    if form.is_valid():
        trs = TestRun.objects.filter(pk__in = pre_process_ids(value = run_ids))

        if form.cleaned_data['plan']:
            trs.update(plan = form.cleaned_data['plan'])

        if form.cleaned_data['build']:
            trs.update(build = form.cleaned_data['build'])

        if form.cleaned_data['errata_id']:
            trs.update(errata_id = form.cleaned_data['errata_id'])

        if form.cleaned_data['manager']:
            trs.update(manager = form.cleaned_data['manager'])
        if values.has_key('default_tester'):
            if values.get('default_tester') and form.cleaned_data['default_tester']:
                trs.update(default_tester = form.cleaned_data['default_tester'])
            else:
                trs.update(default_tester = None)
        if form.cleaned_data['summary']:
            trs.update(summary = form.cleaned_data['summary'])

        if form.cleaned_data['estimated_time']:
            trs.update(estimated_time = form.cleaned_data['estimated_time'])

        if form.cleaned_data['product_version']:
            trs.update(product_version = form.cleaned_data['product_version'])

        if values.has_key('notes'):
            if values['notes'] in (None, ''):
                trs.update(notes = values['notes'])
            if form.cleaned_data['notes']:
                trs.update(notes = form.cleaned_data['notes'])

        if form.cleaned_data['plan_text_version']:
            trs.update(plan_text_version = form.cleaned_data['plan_text_version'])

        if isinstance(form.cleaned_data['status'], int):
            if form.cleaned_data['status']:
                trs.update(stop_date = datetime.now())
            else:
                trs.update(stop_date = None)
    else:
        return forms.errors_to_list(form)

    query = {'pk__in': trs.values_list('pk', flat=True)}
    return TestRun.to_xmlrpc(query)