当前位置: 首页>>代码示例>>Python>>正文


Python RecipeFactory.save方法代码示例

本文整理汇总了Python中normandy.recipes.tests.RecipeFactory.save方法的典型用法代码示例。如果您正苦于以下问题:Python RecipeFactory.save方法的具体用法?Python RecipeFactory.save怎么用?Python RecipeFactory.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在normandy.recipes.tests.RecipeFactory的用法示例。


在下文中一共展示了RecipeFactory.save方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_setting_signature_doesnt_change_canonical_json

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import save [as 别名]
 def test_setting_signature_doesnt_change_canonical_json(self):
     recipe = RecipeFactory(name='unchanged', signed=False)
     serialized = recipe.canonical_json()
     recipe.signature = SignatureFactory()
     recipe.save()
     assert recipe.signature is not None
     assert recipe.canonical_json() == serialized
开发者ID:chartjes,项目名称:normandy,代码行数:9,代码来源:test_models.py

示例2: test_cant_change_signature_and_other_fields

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import save [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'
开发者ID:chartjes,项目名称:normandy,代码行数:9,代码来源:test_models.py

示例3: test_revision_id_increments

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import save [as 别名]
    def test_revision_id_increments(self):
        """Ensure that the revision id is incremented on each save"""
        recipe = RecipeFactory()

        # The factory saves a couple times so revision id is not 0
        revision_id = recipe.revision_id

        recipe.save()
        assert recipe.revision_id == revision_id + 1
开发者ID:MFBrewster,项目名称:normandy,代码行数:11,代码来源:test_models.py

示例4: test_revision_id_doesnt_increment_if_no_changes

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import save [as 别名]
    def test_revision_id_doesnt_increment_if_no_changes(self):
        """
        revision_id should not increment if a recipe is saved with no
        changes.
        """
        recipe = RecipeFactory()

        # The factory saves a couple times so revision id is not 0
        revision_id = recipe.revision_id

        recipe.save()
        assert recipe.revision_id == revision_id
开发者ID:chartjes,项目名称:normandy,代码行数:14,代码来源:test_models.py

示例5: test_update_signature

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import save [as 别名]
    def test_update_signature(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(signed=False)
        recipe.update_signature()
        recipe.save()
        assert recipe.signature is not None
        assert recipe.signature.signature == 'fake signature'
开发者ID:chartjes,项目名称:normandy,代码行数:14,代码来源:test_models.py

示例6: test_signature_is_cleared_if_autograph_unavailable

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import save [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
开发者ID:chartjes,项目名称:normandy,代码行数:14,代码来源:test_models.py

示例7: test_signature_is_updated_if_autograph_available

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import save [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
开发者ID:mythmon,项目名称:normandy,代码行数:14,代码来源:test_models.py

示例8: test_signature_is_updated_if_autograph_available

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import save [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'
开发者ID:chartjes,项目名称:normandy,代码行数:16,代码来源:test_models.py

示例9: test_skip_last_updated

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import save [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
开发者ID:chartjes,项目名称:normandy,代码行数:17,代码来源:test_models.py

示例10: test_history

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import save [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'
开发者ID:amitkumarj441,项目名称:normandy,代码行数:19,代码来源:test_api.py

示例11: test_signatures_update_correctly_on_enable

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import save [as 别名]
    def test_signatures_update_correctly_on_enable(self, mocker):
        mock_autograph = mocker.patch('normandy.recipes.models.Autographer')

        def fake_sign(datas):
            sigs = []
            for d in datas:
                sigs.append({'signature': hashlib.sha256(d).hexdigest()})
            return sigs

        mock_autograph.return_value.sign_data.side_effect = fake_sign

        recipe = RecipeFactory(enabled=False, signed=False)
        recipe.enabled = True
        recipe.save()
        recipe.refresh_from_db()

        assert recipe.signature is not None
        assert recipe.signature.signature == hashlib.sha256(recipe.canonical_json()).hexdigest()
开发者ID:chartjes,项目名称:normandy,代码行数:20,代码来源:test_models.py


注:本文中的normandy.recipes.tests.RecipeFactory.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。