本文整理汇总了Python中normandy.recipes.tests.RecipeFactory.name方法的典型用法代码示例。如果您正苦于以下问题:Python RecipeFactory.name方法的具体用法?Python RecipeFactory.name怎么用?Python RecipeFactory.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类normandy.recipes.tests.RecipeFactory
的用法示例。
在下文中一共展示了RecipeFactory.name方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_skip_last_updated
# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import name [as 别名]
def test_skip_last_updated(self):
# set last_updated to avoid timestamp precision problems
recipe = RecipeFactory(name='one', last_updated=datetime.now() - timedelta(30))
last_updated_1 = recipe.last_updated
recipe.name = 'two'
recipe.save()
last_updated_2 = recipe.last_updated
recipe.name = 'three'
recipe.save(skip_last_updated=True)
last_updated_3 = recipe.last_updated
assert last_updated_1 != last_updated_2
assert last_updated_2 == last_updated_3
示例2: test_cant_change_signature_and_other_fields
# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import name [as 别名]
def test_cant_change_signature_and_other_fields(self):
recipe = RecipeFactory(name='unchanged', signed=False)
recipe.signature = SignatureFactory()
recipe.name = 'changed'
with pytest.raises(ValidationError) as exc_info:
recipe.save()
assert exc_info.value.message == 'Signatures must change alone'
示例3: test_history
# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import name [as 别名]
def test_history(self, api_client):
with reversion.create_revision():
recipe = RecipeFactory(name='version 1')
with reversion.create_revision():
recipe.name = 'version 2'
recipe.save()
with reversion.create_revision():
recipe.name = 'version 3'
recipe.save()
res = api_client.get('/api/v1/recipe/%s/history/' % recipe.id)
assert res.data[0]['recipe']['name'] == 'version 3'
assert res.data[1]['recipe']['name'] == 'version 2'
assert res.data[2]['recipe']['name'] == 'version 1'
示例4: test_signature_is_cleared_if_autograph_unavailable
# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import name [as 别名]
def test_signature_is_cleared_if_autograph_unavailable(self, mocker):
# Mock the Autographer
mock_autograph = mocker.patch('normandy.recipes.models.Autographer')
mock_autograph.return_value.sign_data.side_effect = ImproperlyConfigured
recipe = RecipeFactory(name='unchanged', signed=True)
original_signature = recipe.signature
recipe.name = 'changed'
recipe.save()
assert recipe.name == 'changed'
assert recipe.signature is not original_signature
assert recipe.signature is None
示例5: test_signature_is_updated_if_autograph_available
# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import name [as 别名]
def test_signature_is_updated_if_autograph_available(self, mocked_autograph):
recipe = RecipeFactory(name='unchanged')
original_signature = recipe.signature
assert original_signature is not None
recipe.name = 'changed'
recipe.save()
assert recipe.name == 'changed'
assert recipe.signature is not original_signature
expected_sig = hashlib.sha256(recipe.canonical_json()).hexdigest()
assert recipe.signature.signature == expected_sig
示例6: test_signature_is_updated_if_autograph_available
# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import name [as 别名]
def test_signature_is_updated_if_autograph_available(self, mocker):
# Mock the Autographer
mock_autograph = mocker.patch('normandy.recipes.models.Autographer')
mock_autograph.return_value.sign_data.return_value = [
{'signature': 'fake signature'},
]
recipe = RecipeFactory(name='unchanged', signed=True)
original_signature = recipe.signature
recipe.name = 'changed'
recipe.save()
assert recipe.name == 'changed'
assert recipe.signature is not original_signature
assert recipe.signature.signature == 'fake signature'