def filter(request, query): """Performs a search and returns the resulting list of test cases. :param dict query: a mapping containing these criteria. * author: A Bugzilla login (email address) * attachments: ForeignKey: Attachment * alias: (str) * case_id: (int) * case_status: ForeignKey: Case Stat * category: ForeignKey: :class:`Category` * component: ForeignKey: :class:`Component` * default_tester: ForeignKey: ``Auth.User`` * estimated_time: String: 2h30m30s(recommend) or HH:MM:SS * plan: ForeignKey: :class:`TestPlan` * priority: ForeignKey: :class:`Priority` * category__product: ForeignKey: :class:`Product` * summary: (str) * tags: ForeignKey: :class:`Tags` * create_date: Datetime * is_automated: 1: Only show current 0: show not current * script: (str) :return: list of mappings of found :class:`TestCase`. :rtype: list Example:: # Get all of cases contain 'TCMS' in summary TestCase.filter({'summary__icontain': 'TCMS'}) # Get all of cases create by xkuang TestCase.filter({'author__username': '******'}) # Get all of cases the author name starts with x TestCase.filter({'author__username__startswith': 'x'}) # Get all of cases belong to the plan 1 TestCase.filter({'plan__plan_id': 1}) # Get all of cases belong to the plan create by xkuang TestCase.filter({'plan__author__username': '******'}) # Get cases with ID 12345, 23456, 34567 - Here is only support array so far. TestCase.filter({'case_id__in': [12345, 23456, 34567]}) """ if query.get('estimated_time'): query['estimated_time'] = timedelta2int( pre_process_estimated_time(query.get('estimated_time')) ) deprecate_critetion_attachment(query) return TestCase.to_xmlrpc(query)
def filter_count(request, values={}): """Performs a search and returns the resulting count of cases. :param dict values: a mapping containing same criteria with :meth:`TestCase.filter <tcms.xmlrpc.api.testcase.filter>`. :return: the number of matching cases. :rtype: int .. seealso:: Examples of :meth:`TestCase.filter <tcms.xmlrpc.api.testcase.filter>`. """ if values.get('estimated_time'): values['estimated_time'] = timedelta2int( pre_process_estimated_time(values.get('estimated_time')) ) return distinct_count(TestCase, values)
def clean(self, value): value = super().clean(value) return timedelta2int(value)