Esempio n. 1
0
def filter_components(request, query):
    """
    Description: Performs a search and returns the resulting list of components.

    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                        |
    | initial_owner       | ForeignKey: Auth.User                      |
    | initial_qa_contact  | ForeignKey: Auth.User                      |
    | description         | String                                     |
    +------------------------------------------------------------------+

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

    Example:
    # Get all of components named like 'libvirt'
    >>> Product.filter_components({'name__icontains': 'libvirt'})
    # Get all of components named in product 'Red Hat Enterprise Linux 5'
    >>> Product.filter_components({'product__name': 'Red Hat Enterprise Linux 5'})
    """
    from tcms.management.models import Component

    return Component.to_xmlrpc(query)
Esempio n. 2
0
def filter_components(request, query):
    """Performs a search and returns the resulting list of components.

    :param dict query: a mapping containing following criteria.

        * id: (int) product ID.
        * name: (str) component name.
        * product: ForeignKey: :class:`Product`.
        * initial_owner: ForeignKey: ``Auth.User``.
        * initial_qa_contact: ForeignKey: ``Auth.User``.
        * description str: component description.

    :return: a mapping of found :class:`Component`.
    :rtype: dict

    Example::

        # Get all of components named like 'libvirt'
        >>> Product.filter_components({'name__icontains': 'libvirt'})
        # Get all of components named in product 'product name'
        >>> Product.filter_components({'product__name': 'product name'})
    """
    from tcms.management.models import Component

    return Component.to_xmlrpc(query)
Esempio n. 3
0
def filter_components(request, query):
    """
    Description: Performs a search and returns the resulting list of components.

    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                        |
    | initial_owner       | ForeignKey: Auth.User                      |
    | initial_qa_contact  | ForeignKey: Auth.User                      |
    | description         | String                                     |
    +------------------------------------------------------------------+

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

    Example:
    # Get all of components named like 'libvirt'
    >>> Product.filter_components({'name__icontains': 'libvirt'})
    # Get all of components named in product 'Red Hat Enterprise Linux 5'
    >>> Product.filter_components({'product__name': 'Red Hat Enterprise Linux 5'})
    """
    from tcms.management.models import Component

    return Component.to_xmlrpc(query)
Esempio n. 4
0
def filter_components(request, query):
    """Performs a search and returns the resulting list of components.

    :param dict query: a mapping containing following criteria.

        * id: (int) product ID.
        * name: (str) component name.
        * product: ForeignKey: :class:`Product`.
        * initial_owner: ForeignKey: ``Auth.User``.
        * initial_qa_contact: ForeignKey: ``Auth.User``.
        * description str: component description.

    :return: a mapping of found :class:`Component`.
    :rtype: dict

    Example::

        # Get all of components named like 'libvirt'
        >>> Product.filter_components({'name__icontains': 'libvirt'})
        # Get all of components named in product 'product name'
        >>> Product.filter_components({'product__name': 'product name'})
    """
    from tcms.management.models import Component

    return Component.to_xmlrpc(query)
Esempio n. 5
0
def filter(query):  # pylint: disable=redefined-builtin
    """
    .. function:: XML-RPC Component.filter(query)

        Search and return the resulting list of components.

        :param query: Field lookups for :class:`tcms.management.models.Component`
        :type query: dict
        :return: List of serialized :class:`tcms.management.models.Component` objects
        :rtype: list(dict)
    """
    return Component.to_xmlrpc(query)
Esempio n. 6
0
def get_components(plan_id):
    """
    Description: Get the list of components attached to this plan.

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

    Returns:     Array: An array of component object hashes.

    Example:
    >>> TestPlan.get_components(12345)
    """
    test_plan = TestPlan.objects.get(plan_id=plan_id)

    component_ids = test_plan.component.values_list('id', flat=True)
    query = {'id__in': component_ids}
    return Component.to_xmlrpc(query)
Esempio n. 7
0
def get_components(request, plan_id):
    """Get the list of components attached to this plan.

    :param int plan_id: plan ID.
    :return: list of mappings of found :class:`Component`.
    :rtype: list[dict]

    Example::

        >>> TestPlan.get_components(1)
    """
    tp = TestPlan.objects.get(plan_id=plan_id)

    component_ids = tp.component.values_list('id', flat=True)
    query = {'id__in': component_ids}
    return Component.to_xmlrpc(query)
Esempio n. 8
0
def get_components(request, plan_id):
    """Get the list of components attached to this plan.

    :param int plan_id: plan ID.
    :return: list of mappings of found :class:`Component`.
    :rtype: list[dict]

    Example::

        TestPlan.get_components(1)
    """
    tp = TestPlan.objects.get(plan_id=plan_id)

    component_ids = tp.component.values_list('id', flat=True)
    query = {'id__in': component_ids}
    return Component.to_xmlrpc(query)
Esempio n. 9
0
def get_components(case_id):
    """
    .. function:: XML-RPC TestCase.get_components(case_id)

        Get the list of components attached to this case.

        :param case_id: PK if TestCase
        :type case_id: int
        :return: Serialized list of :class:`tcms.management.models.Component` objects
        :rtype: list(dict)
        :raises: TestCase.DoesNotExist if missing test case matching PK
    """
    test_case = TestCase.objects.get(case_id=case_id)

    component_ids = test_case.component.values_list('id', flat=True)
    query = {'id__in': component_ids}
    return Component.to_xmlrpc(query)
Esempio n. 10
0
def get_components(case_id):
    """
    Description: Get the list of components attached to this case.

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

    Returns:     Array: An array of component object hashes.

    Example:
    >>> TestCase.get_components(12345)
    """
    from tcms.management.models import Component

    test_case = TestCase.objects.get(case_id=case_id)

    component_ids = test_case.component.values_list('id', flat=True)
    query = {'id__in': component_ids}
    return Component.to_xmlrpc(query)
Esempio n. 11
0
def get_components(request, case_id):
    """Get the list of components attached to this case.

    :param case_id: case ID.
    :type case_id: int or str
    :return: a list of mappings of :class:`Component`.
    :rtype: list[dict]

    Example::

        TestCase.get_components(1)
    """
    from tcms.management.models import Component

    tc = TestCase.objects.get(case_id=case_id)

    component_ids = tc.component.values_list('id', flat=True)
    query = {'id__in': component_ids}
    return Component.to_xmlrpc(query)
Esempio n. 12
0
def get_components(request, plan_id):
    """
    Description: Get the list of components attached to this plan.

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

    Returns:     Array: An array of component object hashes.

    Example:
    >>> TestPlan.get_components(12345)
    """
    try:
        tp = TestPlan.objects.get(plan_id=plan_id)
    except:
        raise

    component_ids = tp.component.values_list('id', flat=True)
    query = {'id__in': component_ids}
    return Component.to_xmlrpc(query)
Esempio n. 13
0
def get_components(request, case_id):
    """Get the list of components attached to this case.

    :param case_id: case ID.
    :type case_id: int or str
    :return: a list of mappings of :class:`Component`.
    :rtype: list[dict]

    Example::

        >>> TestCase.get_components(1)
    """
    from tcms.management.models import Component

    tc = TestCase.objects.get(case_id=case_id)

    component_ids = tc.component.values_list('id', flat=True)
    query = {'id__in': component_ids}
    return Component.to_xmlrpc(query)
Esempio n. 14
0
def get_components(request, product):
    """Get the list of components associated with this product.

    :param product: product ID or name.
    :type product: int or str
    :return: a list of mappings of :class:`Component`.
    :rtype: list

    Example::

        # Get with product id
        >>> Product.get_components(61)
        # Get with product name
        >>> Product.get_components('product name')
    """
    from tcms.management.models import Component

    p = pre_check_product(values=product)
    query = {'product': p}
    return Component.to_xmlrpc(query)
Esempio n. 15
0
def get_components(request, product):
    """Get the list of components associated with this product.

    :param product: product ID or name.
    :type product: int or str
    :return: a list of mappings of :class:`Component`.
    :rtype: list

    Example::

        # Get with product id
        >>> Product.get_components(61)
        # Get with product name
        >>> Product.get_components('product name')
    """
    from tcms.management.models import Component

    p = pre_check_product(values=product)
    query = {'product': p}
    return Component.to_xmlrpc(query)
Esempio n. 16
0
def get_components(request, product):
    """
    Description: Get the list of components 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 Component objects.

    Example:
    # Get with product id
    >>> Product.get_components(61)
    # Get with product name
    >>> Product.get_components('Red Hat Enterprise Linux 5')
    """
    from tcms.management.models import Component

    p = pre_check_product(values=product)
    query = {'product': p}
    return Component.to_xmlrpc(query)
Esempio n. 17
0
def get_components(request, case_id):
    """"
    Description: Get the list of components attached to this case.

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

    Returns:     Array: An array of component object hashes.

    Example:
    >>> TestCase.get_components(12345)
    """
    from tcms.management.models import Component

    try:
        tc = TestCase.objects.get(case_id=case_id)
    except:
        raise

    component_ids = tc.component.values_list('id', flat=True)
    query = {'id__in': component_ids}
    return Component.to_xmlrpc(query)
Esempio n. 18
0
def get_components(request, product):
    """
    Description: Get the list of components 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 Component objects.

    Example:
    # Get with product id
    >>> Product.get_components(61)
    # Get with product name
    >>> Product.get_components('Red Hat Enterprise Linux 5')
    """
    from tcms.management.models import Component

    p = pre_check_product(values=product)
    query = {'product': p}
    return Component.to_xmlrpc(query)
Esempio n. 19
0
    def setUp(self):
        super(TestUpdateComponent, self).setUp()

        self.admin = User(username='******',
                          email='*****@*****.**')
        self.staff = User(username='******',
                          email='*****@*****.**')
        self.admin.save()
        self.staff.save()
        self.admin_request = make_http_request(
            user=self.admin,
            user_perm='management.change_component'
        )
        self.staff_request = make_http_request(
            user=self.staff
        )

        from tcms.management.models import Component

        self.new_component = Component(name="New Component",
                                       product_id=1,
                                       description="Test")
        self.new_component.save()
Esempio n. 20
0
class TestUpdateComponent(TestCase):
    def setUp(self):
        super(TestUpdateComponent, self).setUp()

        self.admin = User(username='******',
                          email='*****@*****.**')
        self.staff = User(username='******',
                          email='*****@*****.**')
        self.admin.save()
        self.staff.save()
        self.admin_request = make_http_request(
            user=self.admin,
            user_perm='management.change_component'
        )
        self.staff_request = make_http_request(
            user=self.staff
        )

        from tcms.management.models import Component

        self.new_component = Component(name="New Component",
                                       product_id=1,
                                       description="Test")
        self.new_component.save()

    def tearDown(self):
        super(TestUpdateComponent, self).tearDown()

        self.admin.delete()
        self.staff.delete()
        self.new_component.delete()

    def test_update_component(self):
        try:
            pk = self.new_component.pk
            com = product.update_component(self.admin_request, pk, {
                "name": "Updated."
            })
        except Fault:
            self.fail(AssertMessage.UNEXCEPT_ERROR)
        else:
            self.assertEqual(com['name'], 'Updated.')

    def test_update_component_with_non_exist(self):
        try:
            product.update_component(self.admin_request, 1111, {})
        except Fault as f:
            self.assertEqual(f.faultCode, 404, AssertMessage.SHOULD_BE_404)
        else:
            self.fail(AssertMessage.NOT_VALIDATE_ARGS)

    def test_update_component_with_no_perms(self):
        try:
            product.update_component(self.staff_request, 1, {})
        except Fault as f:
            self.assertEqual(f.faultCode, 403, AssertMessage.SHOULD_BE_403)
        else:
            self.fail(AssertMessage.NOT_VALIDATE_PERMS)

    def test_update_component_with_no_arg(self):
        bad_args = (None, [], {}, ())
        for arg in bad_args:
            try:
                product.update_component(self.admin_request,
                                         self.new_component.pk, arg)
            except Fault as f:
                self.assertEqual(f.faultCode, 400, AssertMessage.SHOULD_BE_400)
            else:
                self.fail(AssertMessage.NOT_VALIDATE_ARGS)

        for arg in bad_args:
            try:
                product.update_component(self.admin_request, arg, {})
            except Fault as f:
                self.assertEqual(f.faultCode, 400, AssertMessage.SHOULD_BE_400)
            else:
                self.fail(AssertMessage.NOT_VALIDATE_ARGS)