本文整理汇总了Python中factories.CategoryFactory.create_batch方法的典型用法代码示例。如果您正苦于以下问题:Python CategoryFactory.create_batch方法的具体用法?Python CategoryFactory.create_batch怎么用?Python CategoryFactory.create_batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类factories.CategoryFactory
的用法示例。
在下文中一共展示了CategoryFactory.create_batch方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filter_categories_by_one_condition
# 需要导入模块: from factories import CategoryFactory [as 别名]
# 或者: from factories.CategoryFactory import create_batch [as 别名]
def test_filter_categories_by_one_condition(self):
"""Test filter_categories_by returns a list of categories that meet
the filtering condition"""
CategoryFactory.create_batch(3, description='generic category')
should_be_missing = CategoryFactory.create(description='other category')
retrieved_categories = (self.project_repo
.filter_categories_by(description='generic category'))
assert len(retrieved_categories) == 3, retrieved_categories
assert should_be_missing not in retrieved_categories, retrieved_categories
示例2: test_filter_categories_by_limit_offset
# 需要导入模块: from factories import CategoryFactory [as 别名]
# 或者: from factories.CategoryFactory import create_batch [as 别名]
def test_filter_categories_by_limit_offset(self):
"""Test that filter_categories_by supports limit and offset options"""
CategoryFactory.create_batch(4)
all_categories = self.project_repo.filter_categories_by()
first_two = self.project_repo.filter_categories_by(limit=2)
last_two = self.project_repo.filter_categories_by(limit=2, offset=2)
assert len(first_two) == 2, first_two
assert len(last_two) == 2, last_two
assert first_two == all_categories[:2]
assert last_two == all_categories[2:]
示例3: get_all_returns_list_of_all_categories
# 需要导入模块: from factories import CategoryFactory [as 别名]
# 或者: from factories.CategoryFactory import create_batch [as 别名]
def get_all_returns_list_of_all_categories(self):
"""Test get_all_categories returns a list of all the existing categories"""
categories = CategoryFactory.create_batch(3)
retrieved_categories = self.project_repo.get_all_categories()
assert isinstance(retrieved_categories, list)
assert len(retrieved_categories) == len(categories), retrieved_categories
for category in retrieved_categories:
assert category in categories, category