本文整理汇总了Python中tests.assert_contains函数的典型用法代码示例。如果您正苦于以下问题:Python assert_contains函数的具体用法?Python assert_contains怎么用?Python assert_contains使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_contains函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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
)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)