本文整理汇总了Python中normandy.recipes.tests.RecipeFactory.create_batch方法的典型用法代码示例。如果您正苦于以下问题:Python RecipeFactory.create_batch方法的具体用法?Python RecipeFactory.create_batch怎么用?Python RecipeFactory.create_batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类normandy.recipes.tests.RecipeFactory
的用法示例。
在下文中一共展示了RecipeFactory.create_batch方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_recipes_used_by
# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import create_batch [as 别名]
def test_recipes_used_by(self):
recipe = RecipeFactory(enabled=True)
assert [recipe] == list(recipe.action.recipes_used_by)
action = ActionFactory()
recipes = RecipeFactory.create_batch(2, action=action, enabled=True)
assert set(action.recipes_used_by) == set(recipes)
示例2: test_update_signatures
# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import create_batch [as 别名]
def test_update_signatures(self, mocker):
# Make sure the test environment is clean. This test is invalid otherwise.
assert Recipe.objects.all().count() == 0
# Mock the Autographer
mock_autograph = mocker.patch('normandy.recipes.models.Autographer')
mock_autograph.return_value.sign_data.return_value = [
{'signature': 'fake signature 1'},
{'signature': 'fake signature 2'},
]
# Make and sign two recipes
RecipeFactory.create_batch(2)
Recipe.objects.all().update_signatures()
# Assert the autographer was used as expected
assert mock_autograph.called
assert mock_autograph.return_value.sign_data.called_with([Whatever(), Whatever()])
signatures = list(Recipe.objects.all().values_list('signature__signature', flat=True))
assert signatures == ['fake signature 1', 'fake signature 2']
示例3: test_recipes_used_by
# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import create_batch [as 别名]
def test_recipes_used_by(self):
approver = UserFactory()
enabler = UserFactory()
recipe = RecipeFactory(approver=approver, enabler=enabler)
assert [recipe] == list(recipe.action.recipes_used_by)
action = ActionFactory()
recipes = RecipeFactory.create_batch(2, action=action, approver=approver, enabler=enabler)
assert set(action.recipes_used_by) == set(recipes)
示例4: test_recipes_used_by_empty
# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import create_batch [as 别名]
def test_recipes_used_by_empty(self):
assert list(ActionFactory().recipes_used_by) == []
action = ActionFactory()
RecipeFactory.create_batch(2, action=action, enabled=False)
assert list(action.recipes_used_by) == []