本文整理汇总了Python中tests.assert_contains函数的典型用法代码示例。如果您正苦于以下问题:Python assert_contains函数的具体用法?Python assert_contains怎么用?Python assert_contains使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_contains函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_join
def test_join(self):
query = (
self.session.query(self.Article)
.join(self.Article.category)
)
query = sort_query(query, 'name', silent=False)
assert_contains('ORDER BY article.name ASC', query)
开发者ID:bjmc,项目名称:sqlalchemy-utils,代码行数:7,代码来源:test_sort_query.py
示例2: test_relation_hybrid_property
def test_relation_hybrid_property(self):
query = (
self.session.query(self.Article)
.join(self.Article.category)
).group_by(self.Article.id)
query = sort_query(query, '-category-articles_count')
assert_contains('ORDER BY (SELECT count(article.id) AS count_1', query)
开发者ID:bjmc,项目名称:sqlalchemy-utils,代码行数:7,代码来源:test_sort_query.py
示例3: test_hybrid_property_descending
def test_hybrid_property_descending(self):
query = self.session.query(self.Category)
query = sort_query(query, '-articles_count')
assert_contains(
'ORDER BY (SELECT count(article.id) AS count_1',
query
)
assert ' DESC' in str(query)
开发者ID:bjmc,项目名称:sqlalchemy-utils,代码行数:8,代码来源:test_sort_query.py
示例4: test_aliased_joined_entity
def test_aliased_joined_entity(self):
alias = sa.orm.aliased(self.Category, name='categories')
query = self.session.query(
self.Article
).join(
alias, self.Article.category
)
query = sort_query(query, '-categories-name')
assert_contains('ORDER BY categories.name DESC', query)
开发者ID:bjmc,项目名称:sqlalchemy-utils,代码行数:9,代码来源:test_sort_query.py
示例5: test_column_property
def test_column_property(self):
self.Category.article_count = sa.orm.column_property(
sa.select([sa.func.count(self.Article.id)])
.where(self.Article.category_id == self.Category.id)
.label('article_count')
)
query = self.session.query(self.Category)
query = sort_query(query, 'article_count')
assert_contains('article_count ASC', query)
开发者ID:bjmc,项目名称:sqlalchemy-utils,代码行数:10,代码来源:test_sort_query.py
示例6: test_assigned_hybrid_property
def test_assigned_hybrid_property(self):
def getter(self):
return self.name
self.Article.some_hybrid = sa.ext.hybrid.hybrid_property(
fget=getter
)
query = self.session.query(self.Article)
query = sort_query(query, 'some_hybrid')
assert_contains('ORDER BY article.name ASC', query)
开发者ID:bjmc,项目名称:sqlalchemy-utils,代码行数:10,代码来源:test_sort_query.py
示例7: test_aliased_hybrid_property
def test_aliased_hybrid_property(self):
alias = sa.orm.aliased(
self.Category,
name='categories'
)
query = (
self.session.query(self.Article)
.outerjoin(alias, self.Article.category)
.options(
sa.orm.contains_eager(self.Article.category, alias=alias)
)
).group_by(alias.id, self.Article.id)
query = sort_query(query, '-categories-articles_count')
assert_contains('ORDER BY (SELECT count(article.id) AS count_1', query)
开发者ID:bjmc,项目名称:sqlalchemy-utils,代码行数:14,代码来源:test_sort_query.py
示例8: test_subqueried_scalar
def test_subqueried_scalar(self):
article_count = (
sa.sql.select(
[sa.func.count(self.Article.id)],
from_obj=[self.Article.__table__]
)
.where(self.Article.category_id == self.Category.id)
.correlate(self.Category.__table__)
)
query = self.session.query(
self.Category, article_count.label('articles')
)
query = sort_query(query, '-articles')
assert_contains('ORDER BY articles DESC', query)
开发者ID:bjmc,项目名称:sqlalchemy-utils,代码行数:15,代码来源:test_sort_query.py
示例9: test_aliased_concat_hybrid_property
def test_aliased_concat_hybrid_property(self):
alias = sa.orm.aliased(
self.Category,
name='aliased'
)
query = (
self.session.query(self.Article)
.outerjoin(alias, self.Article.category)
.options(
sa.orm.contains_eager(self.Article.category, alias=alias)
)
)
query = sort_query(query, 'aliased-full_name')
assert_contains(
'concat(aliased.title, :param_1, aliased.name)', query
)
开发者ID:jace,项目名称:sqlalchemy-utils,代码行数:16,代码来源:test_sort_query.py
示例10: test_annotated_label
def test_annotated_label(self):
query = self.session.query(self.User).order_by(self.User.article_count)
query = make_order_by_deterministic(query)
assert_contains('article_count, "user".id ASC', query)
开发者ID:MSusik,项目名称:sqlalchemy-utils,代码行数:4,代码来源:test_make_order_by_deterministic.py
示例11: test_joined_table_column
def test_joined_table_column(self):
query = self.session.query(self.Article).join(self.Article.category)
query = sort_query(query, 'category-name')
assert_contains('category.name ASC', query)
开发者ID:bjmc,项目名称:sqlalchemy-utils,代码行数:4,代码来源:test_sort_query.py
示例12: test_multiple_columns
def test_multiple_columns(self):
query = self.session.query(self.Article)
query = sort_query(query, 'name', 'id')
assert_contains('article.name ASC, article.id ASC', query)
开发者ID:bjmc,项目名称:sqlalchemy-utils,代码行数:4,代码来源:test_sort_query.py
示例13: test_synonym_property
def test_synonym_property(self):
query = self.session.query(self.Category)
query = sort_query(query, 'name_synonym')
assert_contains('ORDER BY category.name ASC', query)
开发者ID:bjmc,项目名称:sqlalchemy-utils,代码行数:4,代码来源:test_sort_query.py
示例14: test_non_unique_column
def test_non_unique_column(self):
query = self.session.query(self.User).order_by(self.User.name)
query = make_order_by_deterministic(query)
assert_contains('ORDER BY "user".name, "user".id ASC', query)
开发者ID:MSusik,项目名称:sqlalchemy-utils,代码行数:4,代码来源:test_make_order_by_deterministic.py
示例15: test_ascending_order_by
def test_ascending_order_by(self):
query = self.session.query(self.User).order_by(
sa.asc(self.User.name)
)
query = make_order_by_deterministic(query)
assert_contains('ORDER BY "user".name ASC, "user".id ASC', query)
开发者ID:MSusik,项目名称:sqlalchemy-utils,代码行数:6,代码来源:test_make_order_by_deterministic.py
示例16: test_calculated_value_descending
def test_calculated_value_descending(self):
query = self.session.query(
self.Category, sa.func.count(self.Article.id).label('articles')
)
query = sort_query(query, '-articles')
assert_contains('ORDER BY articles DESC', query)
开发者ID:bjmc,项目名称:sqlalchemy-utils,代码行数:6,代码来源:test_sort_query.py
示例17: test_child_class_attribute
def test_child_class_attribute(self):
query = sort_query(
self.session.query(self.TextItem),
'category'
)
assert_contains('ORDER BY article.category ASC', query)
开发者ID:bjmc,项目名称:sqlalchemy-utils,代码行数:6,代码来源:test_sort_query.py
示例18: test_with_ambiguous_column
def test_with_ambiguous_column(self):
query = sort_query(
self.session.query(self.TextItem),
'id'
)
assert_contains('ORDER BY text_item.id ASC', query)
开发者ID:bjmc,项目名称:sqlalchemy-utils,代码行数:6,代码来源:test_sort_query.py
示例19: test_annotated_label_with_descending_order
def test_annotated_label_with_descending_order(self):
query = self.session.query(self.User).order_by(
sa.desc(self.User.article_count)
)
query = make_order_by_deterministic(query)
assert_contains('ORDER BY article_count DESC, "user".id DESC', query)
开发者ID:MSusik,项目名称:sqlalchemy-utils,代码行数:6,代码来源:test_make_order_by_deterministic.py
示例20: test_string_order_by
def test_string_order_by(self):
query = self.session.query(self.User).order_by('name')
query = make_order_by_deterministic(query)
assert_contains('ORDER BY name, "user".id ASC', query)
开发者ID:MSusik,项目名称:sqlalchemy-utils,代码行数:4,代码来源:test_make_order_by_deterministic.py
注:本文中的tests.assert_contains函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论