def filter_criteria(
     pattern: Optional[str],
     collection_name: Optional[str],
     collection_id: Optional[int],
     use_doc: bool,
     use_tags: bool,
 ):
     filter_criteria = []
     if pattern:
         if use_tags:
             filter_criteria.append(Keyword.tags.ilike(
                 glob_to_sql(pattern)))
         else:
             filter_criteria.append(Keyword.name.ilike(
                 glob_to_sql(pattern)))
         if use_doc:
             filter_criteria = [
                 or_(filter_criteria[0],
                     Keyword.doc.ilike(glob_to_sql(pattern)))
             ]
     if collection_name:
         filter_criteria.append(
             Collection.name.ilike(glob_to_sql(collection_name)))
     if collection_id:
         filter_criteria.append(Keyword.collection_id == collection_id)
     return filter_criteria
 def get_all(self,
             *,
             pattern: Optional[str] = None,
             collection_name: Optional[str] = None,
             use_doc: bool = True,
             skip: int = 0,
             limit: int = 100) -> List[Keyword]:
     filter_criteria = []
     if pattern:
         filter_criteria.append(Keyword.name.ilike(glob_to_sql(pattern)), )
         if use_doc:
             filter_criteria = [
                 or_(filter_criteria[0],
                     Keyword.doc.ilike(glob_to_sql(pattern)))
             ]
     if collection_name:
         filter_criteria.append(
             Collection.name.ilike(glob_to_sql(collection_name)))
     return self.session.query(Keyword)\
         .join(Keyword.collection)\
         .filter(*filter_criteria) \
         .order_by(Keyword.name) \
         .offset(skip)\
         .limit(limit) \
         .all()
 def filter_criteria(pattern: Optional[str], libtype: Optional[str]):
     filter_criteria = []
     if pattern:
         filter_criteria.append(Collection.name.ilike(glob_to_sql(pattern)))
     if libtype:
         filter_criteria.append(Collection.type.ilike(glob_to_sql(libtype)))
     return filter_criteria
 def get_all(self, *, pattern: Optional[str] = None,
             libtype: Optional[str] = None,
             skip: int = 0,
             limit: int = 100) -> List[Collection]:
     filter_criteria = []
     if pattern:
         filter_criteria.append(Collection.name.ilike(glob_to_sql(pattern)))
     if libtype:
         filter_criteria.append(Collection.type.ilike(glob_to_sql(libtype)))
     return self._items\
         .filter(*filter_criteria)\
         .order_by(Collection.name)\
         .offset(skip)\
         .limit(limit)\
         .all()
Exemple #5
0
 def filter_criteria(pattern: Optional[str], root_only: bool, use_doc: bool,
                     use_tags: bool):
     filter_criteria = []
     if pattern:
         if use_tags:
             filter_criteria.append(Suite.tags.ilike(glob_to_sql(pattern)))
         else:
             filter_criteria.append(Suite.name.ilike(glob_to_sql(pattern)))
         if use_doc:
             filter_criteria = [
                 or_(filter_criteria[0],
                     Suite.doc.ilike(glob_to_sql(pattern)))
             ]
     if root_only:
         filter_criteria.append(Suite.is_root.is_(True))
     return filter_criteria
 def filter_criteria(pattern: Optional[str], suite_id: Optional[int],
                     use_doc: bool, use_tags: bool):
     filter_criteria = []
     if pattern:
         if use_tags:
             filter_criteria.append(
                 TestCase.tags.ilike(glob_to_sql(pattern)))
         else:
             filter_criteria.append(
                 TestCase.name.ilike(glob_to_sql(pattern)))
         if use_doc:
             filter_criteria = [
                 or_(filter_criteria[0],
                     TestCase.doc.ilike(glob_to_sql(pattern)))
             ]
     if suite_id:
         filter_criteria.append(TestCase.suite_id == suite_id)
     return filter_criteria