当前位置: 首页>>代码示例>>Python>>正文


Python TestTag.string_to_list方法代码示例

本文整理汇总了Python中tcms.management.models.TestTag.string_to_list方法的典型用法代码示例。如果您正苦于以下问题:Python TestTag.string_to_list方法的具体用法?Python TestTag.string_to_list怎么用?Python TestTag.string_to_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tcms.management.models.TestTag的用法示例。


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

示例1: add_tag

# 需要导入模块: from tcms.management.models import TestTag [as 别名]
# 或者: from tcms.management.models.TestTag import string_to_list [as 别名]
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,代码行数:34,代码来源:testcase.py

示例2: add_tag

# 需要导入模块: from tcms.management.models import TestTag [as 别名]
# 或者: from tcms.management.models.TestTag import string_to_list [as 别名]
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,代码行数:34,代码来源:testplan.py

示例3: remove_tag

# 需要导入模块: from tcms.management.models import TestTag [as 别名]
# 或者: from tcms.management.models.TestTag import string_to_list [as 别名]
def remove_tag(request, plan_ids, tags):
    """
    Description: Remove a tag from a plan.

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

                 $tag - String - A single tag to be removed.

    Returns:     Array: Empty on success.

    Example:
    # Remove tag 'foo' from plan 1234
    >>> TestPlan.remove_tag(1234, 'foo')
    # Remove tag 'foo' and 'bar' from plan list [56789, 12345]
    >>> TestPlan.remove_tag([56789, 12345], ['foo', 'bar'])
    # Remove tag 'foo' and 'bar' from plan list '56789, 12345' with String
    >>> TestPlan.remove_tag('56789, 12345', 'foo, bar')
    """
    from tcms.management.models import TestTag

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

    for tp in tps.iterator():
        for tg in tgs.iterator():
            try:
                tp.remove_tag(tag=tg)
            except ObjectDoesNotExist:
                pass
            except:
                raise

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

示例4: remove_tag

# 需要导入模块: from tcms.management.models import TestTag [as 别名]
# 或者: from tcms.management.models.TestTag import string_to_list [as 别名]
def remove_tag(request, case_ids, tags):
    """
    Description: Remove a tag from a case.

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

                 $tags - String/Array - A single or multiple tag to be removed.

    Returns:     Array: Empty on success.

    Example:
    # Remove tag 'foo' from case 1234
    >>> TestCase.remove_tag(1234, 'foo')
    # Remove tag 'foo' and bar from cases list [56789, 12345]
    >>> TestCase.remove_tag([56789, 12345], ['foo', 'bar'])
    # Remove tag 'foo' and 'bar' from cases list '56789, 12345' with String
    >>> TestCase.remove_tag('56789, 12345', 'foo, bar')
    """
    tcs = TestCase.objects.filter(
        case_id__in=pre_process_ids(value=case_ids)
    )
    tgs = TestTag.objects.filter(
        name__in=TestTag.string_to_list(tags)
    )

    for tc in tcs.iterator():
        for tg in tgs.iterator():
            try:
                tc.remove_tag(tg)
            except ObjectDoesNotExist:
                pass
            except:
                raise

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

示例5: clean_tag__name__in

# 需要导入模块: from tcms.management.models import TestTag [as 别名]
# 或者: from tcms.management.models.TestTag import string_to_list [as 别名]
 def clean_tag__name__in(self):
     return TestTag.string_to_list(self.cleaned_data['tag__name__in'])
开发者ID:Aaln1986,项目名称:Nitrate,代码行数:4,代码来源:forms.py

示例6: create

# 需要导入模块: from tcms.management.models import TestTag [as 别名]
# 或者: from tcms.management.models.TestTag import string_to_list [as 别名]
def create(request, values):
    """
    Description: Creates a new Test Case object and stores it in the database.

    Params:      $values - Array/Hash: A reference to a hash or array of hashes with keys and values
                 matching the fields of the test case to be created.
      +----------------------------+----------------+-----------+---------------------------------------+
      | Field                      | Type           | Null      | Description                           |
      +----------------------------+----------------+-----------+---------------------------------------+
      | product                    | Integer        | Required  | ID of Product                         |
      | category                   | Integer        | Required  | ID of Category                        |
      | priority                   | Integer        | Required  | ID of Priority                        |
      | summary                    | String         | Required  |                                       |
      | case_status                | Integer        | Optional  | ID of case status                     |
      | plan                       | Array/Str/Int  | Optional  | ID or List of plan_ids                |
      | component                  | Integer/String | Optional  | ID of Priority                        |
      | default_tester             | String         | Optional  | Login of tester                       |
      | estimated_time             | String         | Optional  | 2h30m30s(recommend) or HH:MM:SS Format|
      | is_automated               | Integer        | Optional  | 0: Manual, 1: Auto, 2: Both           |
      | is_automated_proposed      | Boolean        | Optional  | Default 0                             |
      | script                     | String         | Optional  |                                       |
      | arguments                  | String         | Optional  |                                       |
      | requirement                | String         | Optional  |                                       |
      | alias                      | String         | Optional  | Must be unique                        |
      | action                     | String         | Optional  |                                       |
      | effect                     | String         | Optional  | Expected Result                       |
      | setup                      | String         | Optional  |                                       |
      | breakdown                  | String         | Optional  |                                       |
      | tag                        | Array/String   | Optional  | String Comma separated                |
      | bug                        | Array/String   | Optional  | String Comma separated                |
      | extra_link                 | String         | Optional  | reference link                        |
      +----------------------------+----------------+-----------+---------------------------------------+

    Returns:     Array/Hash: The newly created object hash if a single case was created, or
                             an array of objects if more than one was created. If any single case threw an
                             error during creation, a hash with an ERROR key will be set in its place.

    Example:
    # Minimal test case parameters
    >>> values = {
        'category': 135,
        'product': 61,
        'summary': 'Testing XML-RPC',
        'priority': 1,
    }
    >>> TestCase.create(values)
    """
    from tcms.core import forms
    from tcms.xmlrpc.forms import NewCaseForm

    if not (values.get('category') or values.get('summary')):
        raise ValueError()

    values['component'] = pre_process_ids(values.get('component', []))
    values['plan'] = pre_process_ids(values.get('plan', []))
    values['bug'] = pre_process_ids(values.get('bug', []))
    if values.get('estimated_time'):
        values['estimated_time'] = pre_process_estimated_time(values.get('estimated_time'))

    form = NewCaseForm(values)
    form.populate(values.get('product'))

    if form.is_valid():
        # Create the case
        tc = TestCase.create(author=request.user, values=form.cleaned_data)

        # Add case text to the case
        tc.add_text(
            action=form.cleaned_data['action'] or '',
            effect=form.cleaned_data['effect'] or '',
            setup=form.cleaned_data['setup'] or '',
            breakdown=form.cleaned_data['breakdown'] or '',
        )

        # Add the case to specific plans
        for p in form.cleaned_data['plan']:
            tc.add_to_plan(plan=p)
            del p

        # Add components to the case
        for c in form.cleaned_data['component']:
            tc.add_component(component=c)
            del c

        # Add tag to the case
        for tag in TestTag.string_to_list(values.get('tag', [])):
            t, c = TestTag.objects.get_or_create(name=tag)
            tc.add_tag(tag=t)
    else:
        # Print the errors if the form is not passed validation.
        raise ValueError(forms.errors_to_list(form))

    return get(request, tc.case_id)
开发者ID:Aaln1986,项目名称:Nitrate,代码行数:95,代码来源:testcase.py

示例7: __init__

# 需要导入模块: from tcms.management.models import TestTag [as 别名]
# 或者: from tcms.management.models.TestTag import string_to_list [as 别名]
 def __init__(self, obj, tag):
     self.obj = obj
     self.tag = TestTag.string_to_list(tag)
     self.request = request
开发者ID:tkdchen,项目名称:Nitrate,代码行数:6,代码来源:ajax.py

示例8: clean_tag

# 需要导入模块: from tcms.management.models import TestTag [as 别名]
# 或者: from tcms.management.models.TestTag import string_to_list [as 别名]
 def clean_tag(self):
     return TestTag.objects.filter(
         name__in=TestTag.string_to_list(self.cleaned_data['tag'])
     )
开发者ID:MrSenko,项目名称:Nitrate,代码行数:6,代码来源:forms.py

示例9: clean_tag

# 需要导入模块: from tcms.management.models import TestTag [as 别名]
# 或者: from tcms.management.models.TestTag import string_to_list [as 别名]
 def clean_tag(self):
     tags = []
     if self.cleaned_data['tag']:
         tag_names = TestTag.string_to_list(self.cleaned_data['tag'])
         tags = TestTag.get_or_create_many_by_name(tag_names)
     return tags
开发者ID:yangxiangfu,项目名称:Nitrate,代码行数:8,代码来源:forms.py


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