コード例 #1
0
def filter(request, values={}):
    """
    Description: Performs a search and returns the resulting list of test cases.

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

        +----------------------------------------------------------------+
        |               Case-Run Search Parameters                       |
        +----------------------------------------------------------------+
        |        Key          |          Valid Values                    |
        | case_run_id         | Integer                                  |
        | assignee            | ForeignKey: Auth.User                    |
        | build               | ForeignKey: Build                        |
        | case                | ForeignKey: Test Case                    |
        | case_run_status     | ForeignKey: Case Run Status              |
        | is_current          | 1: Only show current 0: show not current |
        | notes               | String                                   |
        | run                 | ForeignKey: Test Run                     |
        | tested_by           | ForeignKey: Auth.User                    |
        | running_date        | Datetime                                 |
        | close_date          | Datetime                                 |
        +----------------------------------------------------------------+

    Returns:     Object: Matching test cases are retuned in a list of hashes.

    Example:
    # Get all case runs contain 'TCMS' in case summary
    >>> TestCaseRun.filter({'case__summary__icontain': 'TCMS'})
    """
    return TestCaseRun.to_xmlrpc(values)
コード例 #2
0
ファイル: testcaserun.py プロジェクト: xltian/nitrate
def filter(request, values = {}):
    """
    Description: Performs a search and returns the resulting list of test cases.

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

        +----------------------------------------------------------------+
        |               Case-Run Search Parameters                       |
        +----------------------------------------------------------------+
        |        Key          |          Valid Values                    |
        | case_run_id         | Integer                                  |
        | assignee            | ForeignKey: Auth.User                    |
        | build               | ForeignKey: Build                        |
        | case                | ForeignKey: Test Case                    |
        | case_run_status     | ForeignKey: Case Run Status              |
        | is_current          | 1: Only show current 0: show not current |
        | notes               | String                                   |
        | run                 | ForeignKey: Test Run                     |
        | tested_by           | ForeignKey: Auth.User                    |
        | running_date        | Datetime                                 |
        | close_date          | Datetime                                 |
        +----------------------------------------------------------------+

    Returns:     Object: Matching test cases are retuned in a list of hashes.

    Example:
    # Get all case runs contain 'TCMS' in case summary
    >>> TestCaseRun.filter({'case__summary__icontain': 'TCMS'})
    """
    return TestCaseRun.to_xmlrpc(values)
コード例 #3
0
ファイル: build.py プロジェクト: xltian/nitrate
def get_caseruns(request, build_id):
    """
    Description: Returns the list of case-runs that this Build is used in.

    Params:      $id -  Integer: Build ID.

    Returns:     Array: List of case-run object hashes.

    Example:
    >>> Build.get_caseruns(1234)
    """
    from tcms.apps.testruns.models import TestCaseRun

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

    return TestCaseRun.to_xmlrpc(query)
コード例 #4
0
ファイル: build.py プロジェクト: erichuanggit/Nitrate
def get_caseruns(request, build_id):
    """
    Description: Returns the list of case-runs that this Build is used in.

    Params:      $id -  Integer: Build ID.

    Returns:     Array: List of case-run object hashes.

    Example:
    >>> Build.get_caseruns(1234)
    """
    from tcms.apps.testruns.models import TestCaseRun

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

    return TestCaseRun.to_xmlrpc(query)
コード例 #5
0
ファイル: testrun.py プロジェクト: xltian/nitrate
def get_test_case_runs(request, run_id, is_current = None):
    """
    Description: Get the list of cases that this run is linked to.

    Params:      $run_id - Integer: An integer representing the ID in the database
                                    for this run.

                 $is_current - Boolean: True/1 to only include the current set (what is displayed
                                        in the web page) False/0: to return all, current and historical.

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

    Example:
    # Get all of case runs
    >>> TestRun.get_test_case_runs(1193)
    # Get the cases runs in executing
    >>> TestRun.get_test_case_runs(1193, 1)
    """
    query = {'run__run_id': run_id}
    if is_current is not None:
        query['is_current'] = is_current
    return TestCaseRun.to_xmlrpc(query)
コード例 #6
0
def get_test_case_runs(request, run_id, is_current=None):
    """
    Description: Get the list of cases that this run is linked to.

    Params:      $run_id - Integer: An integer representing the ID in the database
                                    for this run.

                 $is_current - Boolean: True/1 to only include the current set (what is displayed
                                        in the web page) False/0: to return all, current and historical.

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

    Example:
    # Get all of case runs
    >>> TestRun.get_test_case_runs(1193)
    # Get the cases runs in executing
    >>> TestRun.get_test_case_runs(1193, 1)
    """
    query = {'run__run_id': run_id}
    if is_current is not None:
        query['is_current'] = is_current
    return TestCaseRun.to_xmlrpc(query)
コード例 #7
0
def update(request, case_run_ids, values):
    """
    Description: Updates the fields of the selected case-runs.

    Params:      $caserun_ids - Integer/String/Array
                        Integer: A single TestCaseRun ID.
                        String:  A comma separates string of TestCaseRun IDs for batch
                                 processing.
                        Array:   An array of TestCaseRun IDs for batch mode processing

                 $values - Hash of keys matching TestCaseRun fields and the new values
                 to set each field to.
                         +--------------------+----------------+
                         | Field              | Type           |
                         +--------------------+----------------+
                         | build              | Integer        |
                         | assignee           | Integer        |
                         | case_run_status    | Integer        |
                         | notes              | String         |
                         | sortkey            | Integer        |
                         +--------------------+----------------+

    Returns:     Hash/Array: In the case of a single object, it is returned. If a
                 list was passed, it returns an array of object hashes. If the
                 update on any particular object failed, the hash will contain a
                 ERROR key and the message as to why it failed.

    Example:
    # Update alias to 'tcms' for case 12345 and 23456
    >>> TestCaseRun.update([12345, 23456], {'assignee': 2206})
    """
    from datetime import datetime
    from tcms.core import forms
    from tcms.apps.testruns.forms import XMLRPCUpdateCaseRunForm

    pks_to_update = pre_process_ids(case_run_ids)

    tcrs = TestCaseRun.objects.filter(pk__in=pks_to_update)
    form = XMLRPCUpdateCaseRunForm(values)

    if form.is_valid():
        data = {}

        if form.cleaned_data['build']:
            data['build'] = form.cleaned_data['build']

        if form.cleaned_data['assignee']:
            data['assignee'] = form.cleaned_data['assignee']

        if form.cleaned_data['case_run_status']:
            data['case_run_status'] = form.cleaned_data['case_run_status']
            data['tested_by'] = request.user
            data['close_date'] = datetime.now()

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

        if form.cleaned_data['sortkey'] is not None:
            data['sortkey'] = form.cleaned_data['sortkey']

        tcrs.update(**data)

    else:
        raise ValueError(forms.errors_to_list(form))

    query = {'pk__in': pks_to_update}
    return TestCaseRun.to_xmlrpc(query)
コード例 #8
0
ファイル: testcaserun.py プロジェクト: xltian/nitrate
def update(request, case_run_ids, values):
    """
    Description: Updates the fields of the selected case-runs.

    Params:      $caserun_ids - Integer/String/Array
                        Integer: A single TestCaseRun ID.
                        String:  A comma separates string of TestCaseRun IDs for batch
                                 processing.
                        Array:   An array of TestCaseRun IDs for batch mode processing

                 $values - Hash of keys matching TestCaseRun fields and the new values
                 to set each field to.
                         +--------------------+----------------+
                         | Field              | Type           |
                         +--------------------+----------------+
                         | build              | Integer        |
                         | assignee           | Integer        |
                         | case_run_status    | Integer        |
                         | notes              | String         |
                         | sortkey            | Integer        |
                         +--------------------+----------------+

    Returns:     Hash/Array: In the case of a single object, it is returned. If a
                 list was passed, it returns an array of object hashes. If the
                 update on any particular object failed, the hash will contain a
                 ERROR key and the message as to why it failed.

    Example:
    # Update alias to 'tcms' for case 12345 and 23456
    >>> TestCaseRun.update([12345, 23456], {'assignee': 2206})
    """
    from datetime import datetime
    from tcms.core import forms
    from tcms.apps.testruns.forms import XMLRPCUpdateCaseRunForm

    tcrs = TestCaseRun.objects.filter(
        pk__in = pre_process_ids(case_run_ids)
    )
    form = XMLRPCUpdateCaseRunForm(values)

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

        if form.cleaned_data['assignee']:
            tcrs.update(assignee = form.cleaned_data['assignee'])

        if form.cleaned_data['case_run_status']:
            tcrs.update(case_run_status = form.cleaned_data['case_run_status'])
            tcrs.update(tested_by = request.user)
            tcrs.update(close_date = datetime.now())

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

        if form.cleaned_data['sortkey']:
            tcrs.update(sortkey = form.cleaned_data['sortkey'])
    else:
        return forms.errors_to_list(form)

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