• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.pre_process_ids函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tcms.xmlrpc.utils.pre_process_ids函数的典型用法代码示例。如果您正苦于以下问题:Python pre_process_ids函数的具体用法?Python pre_process_ids怎么用?Python pre_process_ids使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了pre_process_ids函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: detach_issue

def detach_issue(request, case_run_ids, issue_keys):
    """Remove one or more issues to the selected test case-runs.

    :param case_run_ids: give one or more case run IDs. It could be an integer,
        a string containing comma separated IDs, or a list of int each of them
        is a case run ID.
    :type run_ids: int, str or list
    :param issue_keys: give one or more case run IDs. It could be an integer,
        a string containing comma separated IDs, or a list of int each of them
        is a case run ID.
    :type issue_keys: int, str or list
    :return: a list which is empty on success or a list of mappings with
        failure codes if a failure occured.
    :rtype: list

    Example::

        # Remove issue 1000 from case run 1
        >>> TestCaseRun.detach_issue(1, 1000)
        # Remove issues [1000, 2000] from case runs list [1, 2]
        >>> TestCaseRun.detach_issue([1, 2], [1000, 2000])
        # Remove issues '1000, 2000' from case runs list '1, 2' with String
        >>> TestCaseRun.detach_issue('1, 2', '1000, 2000')
    """
    tcrs = TestCaseRun.objects.filter(pk__in=pre_process_ids(case_run_ids))
    issue_keys = pre_process_ids(issue_keys)

    for tcr in tcrs.iterator():
        for issue_key in issue_keys:
            tcr.remove_issue(issue_key=issue_key, case_run=tcr)
开发者ID:tkdchen,项目名称:Nitrate,代码行数:30,代码来源:testcaserun.py


示例2: add_cases

def add_cases(request, run_ids, case_ids):
    """
    Description: Add one or more cases to the selected test runs.

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

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

    Returns:     Array: empty on success or an array of hashes with failure
                        codes if a failure occured.

    Example:
    # Add case id 54321 to run 1234
    >>> TestRun.add_cases(1234, 54321)
    # Add case ids list [1234, 5678] to run list [56789, 12345]
    >>> TestRun.add_cases([56789, 12345], [1234, 5678])
    # Add case ids list '1234, 5678' to run list '56789, 12345' with String
    >>> TestRun.add_cases('56789, 12345', '1234, 5678')
    """
    trs = TestRun.objects.filter(run_id__in=pre_process_ids(run_ids))
    tcs = TestCase.objects.filter(case_id__in=pre_process_ids(case_ids))

    for tr in trs.iterator():
        for tc in tcs.iterator():
            tr.add_case_run(case=tc)

    return
开发者ID:MrSenko,项目名称:Nitrate,代码行数:29,代码来源:testrun.py


示例3: detach_bug

def detach_bug(request, case_ids, bug_ids):
    """
    Description: Remove one or more bugs to the selected test cases.

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

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

    Returns:     Array: empty on success or an array of hashes with failure
                 codes if a failure occured.

    Example:
    # Remove bug id 54321 from case 1234
    >>> TestCase.detach_bug(1234, 54321)
    # Remove bug ids list [1234, 5678] from cases list [56789, 12345]
    >>> TestCase.detach_bug([56789, 12345], [1234, 5678])
    # Remove bug ids list '1234, 5678' from cases list '56789, 12345' with String
    >>> TestCase.detach_bug('56789, 12345', '1234, 5678')
    """
    case_ids = pre_process_ids(case_ids)
    bug_ids = pre_process_ids(bug_ids)

    tcs = TestCase.objects.filter(case_id__in=case_ids).iterator()
    for tc in tcs:
        for opk in bug_ids:
            try:
                tc.remove_bug(bug_id=opk)
            except ObjectDoesNotExist:
                pass

    return
开发者ID:Aaln1986,项目名称:Nitrate,代码行数:33,代码来源:testcase.py


示例4: add_component

def add_component(request, plan_ids, component_ids):
    """
    Description: Adds one or more components to the selected test plan.

    Params:      $plan_ids - Integer/Array/String: An integer representing the ID of the plan in the database.
                 $component_ids - Integer/Array/String - The component ID, an array of Component IDs
                                  or a comma separated list of component IDs.

    Returns:     Array: empty on success or an array of hashes with failure
                        codes if a failure occured.

    Example:
    # Add component id 54321 to plan 1234
    >>> TestPlan.add_component(1234, 54321)
    # Add component ids list [1234, 5678] to plan list [56789, 12345]
    >>> TestPlan.add_component([56789, 12345], [1234, 5678])
    # Add component ids list '1234, 5678' to plan list '56789, 12345' with String
    >>> TestPlan.add_component('56789, 12345', '1234, 5678')
    """
    # FIXME: optimize this method to reduce possible huge number of SQLs

    tps = TestPlan.objects.filter(
        plan_id__in=pre_process_ids(value=plan_ids)
    )
    cs = Component.objects.filter(
        id__in=pre_process_ids(value=component_ids)
    )

    for tp in tps.iterator():
        for c in cs.iterator():
            tp.add_component(c)

    return
开发者ID:MrSenko,项目名称:Nitrate,代码行数:33,代码来源:testplan.py


示例5: link_plan

def link_plan(request, case_ids, plan_ids):
    """"
    Description: Link test cases to the given plan.

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

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

    Returns:     Array: empty on success or an array of hashes with failure
                        codes if a failure occurs

    Example:
    # Add case 1234 to plan id 54321
    >>> TestCase.link_plan(1234, 54321)
    # Add case ids list [56789, 12345] to plan list [1234, 5678]
    >>> TestCase.link_plan([56789, 12345], [1234, 5678])
    # Add case ids list 56789 and 12345 to plan list 1234 and 5678 with String
    >>> TestCase.link_plan('56789, 12345', '1234, 5678')
    """
    from tcms.apps.testplans.models import TestPlan

    case_ids = pre_process_ids(value=case_ids)
    plan_ids = pre_process_ids(value=plan_ids)

    tcs = TestCase.objects.filter(pk__in=case_ids)
    tps = TestPlan.objects.filter(pk__in=plan_ids)

    # Check the non-exist case ids.
    if tcs.count() < len(case_ids):
        raise ObjectDoesNotExist(
            "TestCase", compare_list(case_ids,
                                     tcs.values_list('pk',
                                                     flat=True).iterator())
        )

    # Check the non-exist plan ids.
    if tps.count() < len(plan_ids):
        raise ObjectDoesNotExist(
            "TestPlan", compare_list(plan_ids,
                                     tps.values_list('pk',
                                                     flat=True).iterator())
        )

    # Link the plans to cases
    for tc in tcs.iterator():
        for tp in tps.iterator():
            tc.add_to_plan(tp)

    return
开发者ID:erichuanggit,项目名称:Nitrate,代码行数:51,代码来源:testcase.py


示例6: test_pre_process_ids_with_others

    def test_pre_process_ids_with_others(self):
        try:
            U.pre_process_ids((1,))
        except TypeError as e:
            self.assertEqual(str(e), 'Unrecognizable type of ids')
        else:
            self.fail("Missing validations.")

        try:
            U.pre_process_ids(dict(a=1))
        except TypeError as e:
            self.assertEqual(str(e), 'Unrecognizable type of ids')
        else:
            self.fail("Missing validations.")
开发者ID:Aaln1986,项目名称:Nitrate,代码行数:14,代码来源:test_utils.py


示例7: calculate_average_estimated_time

def calculate_average_estimated_time(request, case_ids):
    """
    Description: Returns an average estimated time for cases.

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

    Returns:     String: Time in "HH:MM:SS" format.

    Example:
    >>> TestCase.calculate_average_time([609, 610, 611])
    """
    from datetime import timedelta
    from tcms.core.utils.xmlrpc import SECONDS_PER_DAY

    tcs = TestCase.objects.filter(
        pk__in=pre_process_ids(case_ids)).only('estimated_time')
    time = timedelta(0)
    case_count = 0
    for tc in tcs.iterator():
        case_count += 1
        time += tc.estimated_time

    seconds = time.seconds + (time.days * SECONDS_PER_DAY)
    # iterator will not populate cache so here will access db again
    # seconds = seconds / len(tcs)
    seconds = seconds / case_count

    return '%02i:%02i:%02i' % (
        seconds / 3600,  # Hours
        seconds / 60,  # Minutes
        seconds % 60  # Seconds
    )
开发者ID:erichuanggit,项目名称:Nitrate,代码行数:32,代码来源:testcase.py


示例8: notification_remove_cc

def notification_remove_cc(request, case_ids, cc_list):
    '''
    Description: Remove email addresses from the notification CC list of specific TestCases

    Params:      $case_ids - Integer/Array: one or more TestCase IDs

                 $cc_list - Array: contians the email addresses that will
                            be removed from each TestCase indicated by case_ids.

    Returns:     JSON. When succeed, status is 0, and message maybe empty or
                 anything else that depends on the implementation. If something
                 wrong, status will be 1 and message will be a short description
                 to the error.
    '''

    try:
        validate_cc_list(cc_list)
    except (TypeError, ValidationError):
        raise

    try:
        tc_ids = pre_process_ids(case_ids)

        for tc in TestCase.objects.filter(pk__in=tc_ids).iterator():
            tc.emailing.cc_list.filter(email__in=cc_list).delete()
    except (TypeError, ValueError, Exception):
        raise
开发者ID:erichuanggit,项目名称:Nitrate,代码行数:27,代码来源:testcase.py


示例9: get_bugs

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.

    Returns:     Array: An array of bug object hashes.

    Example:
    # Get bugs belong to ID 12345
    >>> TestRun.get_bugs(12345)
    # Get bug belong to run ids list [12456, 23456]
    >>> TestRun.get_bugs([12456, 23456])
    # Get bug belong to run ids list 12456 and 23456 with string
    >>> TestRun.get_bugs('12456, 23456')
    """
    from tcms.testcases.models import TestCaseBug

    trs = TestRun.objects.filter(
        run_id__in=pre_process_ids(value=run_ids)
    )
    tcrs = TestCaseRun.objects.filter(
        run__run_id__in=trs.values_list('run_id', flat=True)
    )

    query = {'case_run__case_run_id__in': tcrs.values_list('case_run_id',
                                                           flat=True)}
    return TestCaseBug.to_xmlrpc(query)
开发者ID:MrSenko,项目名称:Nitrate,代码行数:30,代码来源:testrun.py


示例10: calculate_total_estimated_time

def calculate_total_estimated_time(request, case_ids):
    """
    Description: Returns an total estimated time for cases.

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

    Returns:     String: Time in "HH:MM:SS" format.

    Example:
    >>> TestCase.calculate_total_time([609, 610, 611])
    """
    from datetime import timedelta
    from tcms.core.utils.xmlrpc import SECONDS_PER_DAY

    tcs = TestCase.objects.filter(
        pk__in=pre_process_ids(case_ids)).only('estimated_time')
    time = timedelta(0)
    for tc in tcs.iterator():
        time += tc.estimated_time

    seconds = time.seconds + (time.days * SECONDS_PER_DAY)

    return '%02i:%02i:%02i' % (
        seconds / 3600,  # Hours
        seconds / 60,  # Minutes
        seconds % 60  # Seconds
    )
开发者ID:erichuanggit,项目名称:Nitrate,代码行数:27,代码来源:testcase.py


示例11: add_comment

def add_comment(request, case_ids, comment):
    """
    Description: Adds comments to selected test cases.

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

                 $comment - String - The comment

    Returns:     Array: empty on success or an array of hashes with failure
                        codes if a failure occured.

    Example:
    # Add comment 'foobar' to case 1234
    >>> TestCase.add_comment(1234, 'foobar')
    # Add 'foobar' to cases list [56789, 12345]
    >>> TestCase.add_comment([56789, 12345], 'foobar')
    # Add 'foobar' to cases list '56789, 12345' with String
    >>> TestCase.add_comment('56789, 12345', 'foobar')
    """
    from tcms.xmlrpc.utils import Comment

    object_pks = pre_process_ids(value=case_ids)
    c = Comment(
        request=request,
        content_type='testcases.testcase',
        object_pks=object_pks,
        comment=comment
    )

    return c.add()
开发者ID:Aaln1986,项目名称:Nitrate,代码行数:31,代码来源:testcase.py


示例12: add_tag

def add_tag(request, case_ids, tags):
    """
    Description: Add one or more tags to the selected test cases.

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

                $tags - String/Array - A single tag, an array of tags,
                        or a comma separated list of tags.

    Returns:    Array: empty on success or an array of hashes with failure
                       codes if a failure occured.

    Example:
    # Add tag 'foobar' to case 1234
    >>> TestCase.add_tag(1234, 'foobar')
    # Add tag list ['foo', 'bar'] to cases list [12345, 67890]
    >>> TestCase.add_tag([12345, 67890], ['foo', 'bar'])
    # Add tag list ['foo', 'bar'] to cases list [12345, 67890] with String
    >>> TestCase.add_tag('12345, 67890', 'foo, bar')
    """
    tcs = TestCase.objects.filter(
        case_id__in=pre_process_ids(value=case_ids))

    tags = TestTag.string_to_list(tags)

    for tag in tags:
        t, c = TestTag.objects.get_or_create(name=tag)
        for tc in tcs.iterator():
            tc.add_tag(tag=t)

    return
开发者ID:Aaln1986,项目名称:Nitrate,代码行数:32,代码来源:testcase.py


示例13: calculate_total_estimated_time

def calculate_total_estimated_time(request, case_ids):
    """
    Description: Returns an total estimated time for cases.

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

    Returns:     String: Time in "HH:MM:SS" format.

    Example:
    >>> TestCase.calculate_total_time([609, 610, 611])
    """
    from django.db.models import Sum

    tcs = TestCase.objects.filter(
        pk__in=pre_process_ids(case_ids)).only('estimated_time')

    if not tcs.exists():
        raise ValueError('Please input valid case Id')

    # aggregate Sum return integer directly rather than timedelta
    seconds = tcs.aggregate(Sum('estimated_time')).get('estimated_time__sum')

    m, s = divmod(seconds, 60)
    h, m = divmod(m, 60)
    # TODO: return h:m:s or d:h:m
    return '%02i:%02i:%02i' % (h, m, s)
开发者ID:Aaln1986,项目名称:Nitrate,代码行数:26,代码来源:testcase.py


示例14: notification_remove_cc

def notification_remove_cc(request, case_ids, cc_list):
    '''
    Description: Remove email addresses from the notification CC list of specific TestCases

    Params:      $case_ids - Integer/Array: one or more TestCase IDs

                 $cc_list - Array: contians the email addresses that will
                            be removed from each TestCase indicated by case_ids.

    Returns:     JSON. When succeed, status is 0, and message maybe empty or
                 anything else that depends on the implementation. If something
                 wrong, status will be 1 and message will be a short description
                 to the error.
    '''

    try:
        validate_cc_list(cc_list)
    except (TypeError, ValidationError):
        raise

    try:
        tc_ids = pre_process_ids(case_ids)
        cursor = connection.writer_cursor
        ids_values = ",".join(itertools.repeat('%s', len(tc_ids)))
        email_values = ",".join(itertools.repeat('%s', len(cc_list)))
        sql = TC_REMOVE_CC % (ids_values, email_values)
        tc_ids.extend(cc_list)
        cursor.execute(sql, tc_ids)
        transaction.commit_unless_managed()
    except (TypeError, ValueError, Exception):
        raise
开发者ID:Aaln1986,项目名称:Nitrate,代码行数:31,代码来源:testcase.py


示例15: notification_add_cc

def notification_add_cc(request, case_ids, cc_list):
    '''
    Description: Add email addresses to the notification CC list of specific TestCases

    Params:      $case_ids - Integer/Array: one or more TestCase IDs

                 $cc_list - Array: one or more Email addresses, which will be
                            added to each TestCase indicated by the case_ids.

    Returns:     JSON. When succeed, status is 0, and message maybe empty or
                 anything else that depends on the implementation. If something
                 wrong, status will be 1 and message will be a short description
                 to the error.
    '''

    try:
        validate_cc_list(cc_list)
    except (TypeError, ValidationError):
        raise

    try:
        tc_ids = pre_process_ids(case_ids)

        for tc in TestCase.objects.filter(pk__in=tc_ids).iterator():
            # First, find those that do not exist yet.
            existing_cc = tc.emailing.get_cc_list()
            adding_cc = list(set(cc_list) - set(existing_cc))

            tc.emailing.add_cc(adding_cc)

    except (TypeError, ValueError, Exception):
        raise
开发者ID:Aaln1986,项目名称:Nitrate,代码行数:32,代码来源:testcase.py


示例16: add_tag

def add_tag(request, plan_ids, tags):
    """
    Description: Add one or more tags to the selected test plans.

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

                  $tags - String/Array - A single tag, an array of tags,
                      or a comma separated list of tags.

    Returns:     Array: empty on success or an array of hashes with failure
                  codes if a failure occured.

    Example:
    # Add tag 'foobar' to plan 1234
    >>> TestPlan.add_tag(1234, 'foobar')
    # Add tag list ['foo', 'bar'] to plan list [12345, 67890]
    >>> TestPlan.add_tag([12345, 67890], ['foo', 'bar'])
    # Add tag list ['foo', 'bar'] to plan list [12345, 67890] with String
    >>> TestPlan.add_tag('12345, 67890', 'foo, bar')
    """
    # FIXME: this could be optimized to reduce possible huge number of SQLs

    tps = TestPlan.objects.filter(plan_id__in=pre_process_ids(value=plan_ids))
    tags = TestTag.string_to_list(tags)

    for tag in tags:
        t, c = TestTag.objects.get_or_create(name=tag)
        for tp in tps.iterator():
            tp.add_tag(tag=t)

    return
开发者ID:MrSenko,项目名称:Nitrate,代码行数:32,代码来源:testplan.py


示例17: test_pre_process_ids_with_string

    def test_pre_process_ids_with_string(self):
        try:
            U.pre_process_ids(["a", "b"])
        except ValueError as e:
            pass
        except Exception:
            self.fail("Unexcept error occurs.")
        else:
            self.fail("Missing validations.")

        try:
            U.pre_process_ids("[email protected]@[email protected]")
        except ValueError as e:
            pass
        except Exception:
            self.fail("Unexcept error occurs.")
        else:
            self.fail("Missing validations.")
开发者ID:Aaln1986,项目名称:Nitrate,代码行数:18,代码来源:test_utils.py



注:本文中的tcms.xmlrpc.utils.pre_process_ids函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tconfig.TConfig类代码示例发布时间:2022-05-27
下一篇:
Python models.TestTag类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap