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


Python RecipeFactory.revise方法代码示例

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


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

示例1: test_delete_pending_approval_request_on_revise

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import revise [as 别名]
    def test_delete_pending_approval_request_on_revise(self):
        recipe = RecipeFactory(name="old")
        approval = ApprovalRequestFactory(revision=recipe.latest_revision)
        recipe.revise(name="new")

        with pytest.raises(ApprovalRequest.DoesNotExist):
            ApprovalRequest.objects.get(pk=approval.pk)
开发者ID:rehandalal,项目名称:normandy,代码行数:9,代码来源:test_models.py

示例2: test_only_signed_when_approved_and_enabled

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import revise [as 别名]
    def test_only_signed_when_approved_and_enabled(self, mocked_autograph):
        sign_data_mock = mocked_autograph.return_value.sign_data
        # This uses the signer, so do it first
        action = ActionFactory()
        sign_data_mock.reset_mock()

        sign_data_mock.side_effect = Exception("Can't sign yet")
        recipe = RecipeFactory(name="unchanged", action=action)
        assert not recipe.enabled
        assert not recipe.is_approved
        assert recipe.signature is None

        # Updating does not generate a signature
        recipe.revise(name="changed")
        assert recipe.signature is None

        # Approving does not sign the recipe
        rev = recipe.latest_revision
        approval_request = rev.request_approval(UserFactory())
        approval_request.approve(UserFactory(), "r+")
        recipe.refresh_from_db()
        assert recipe.signature is None
        mocked_autograph.return_value.sign_data.assert_not_called()

        # Enabling signs the recipe
        mocked_autograph.return_value.sign_data.side_effect = fake_sign
        rev.enable(UserFactory())
        recipe.refresh_from_db()
        expected_sig = fake_sign([recipe.canonical_json()])[0]["signature"]
        assert recipe.signature.signature == expected_sig
        assert mocked_autograph.return_value.sign_data.called_once()
开发者ID:rehandalal,项目名称:normandy,代码行数:33,代码来源:test_models.py

示例3: test_enabled_state_carried_over_on_approval

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import revise [as 别名]
 def test_enabled_state_carried_over_on_approval(self):
     recipe = RecipeFactory(approver=UserFactory(), enabler=UserFactory())
     carryover_from = recipe.approved_revision.enabled_state
     recipe.revise(name="New name")
     approval_request = recipe.latest_revision.request_approval(UserFactory())
     approval_request.approve(UserFactory(), "r+")
     assert recipe.enabled
     assert recipe.approved_revision.enabled_state.carryover_from == carryover_from
开发者ID:rehandalal,项目名称:normandy,代码行数:10,代码来源:test_models.py

示例4: test_recipe_doesnt_revise_when_clean

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import revise [as 别名]
    def test_recipe_doesnt_revise_when_clean(self):
        recipe = RecipeFactory(name="my name")

        revision_id = recipe.revision_id
        last_updated = recipe.last_updated

        recipe.revise(name="my name")
        assert revision_id == recipe.revision_id
        assert last_updated == recipe.last_updated
开发者ID:rehandalal,项目名称:normandy,代码行数:11,代码来源:test_models.py

示例5: test_can_update_extensions_no_longer_in_use

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import revise [as 别名]
 def test_can_update_extensions_no_longer_in_use(self, api_client, storage):
     xpi = WebExtensionFileFactory()
     e = ExtensionFactory(xpi__from_func=xpi.open)
     a = ActionFactory(name="opt-out-study")
     r = RecipeFactory(action=a, arguments={"extensionId": e.id})
     r.revise(arguments={"extensionId": 0})
     res = api_client.patch(f"/api/v3/extension/{e.id}/", {"name": "new name"})
     assert res.status_code == 200
     assert res.data["name"] == "new name"
开发者ID:rehandalal,项目名称:normandy,代码行数:11,代码来源:test_api.py

示例6: test_can_delete_extensions_no_longer_in_use

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import revise [as 别名]
 def test_can_delete_extensions_no_longer_in_use(self, api_client, storage):
     xpi = WebExtensionFileFactory()
     e = ExtensionFactory(xpi__from_func=xpi.open)
     a = ActionFactory(name="opt-out-study")
     r = RecipeFactory(action=a, arguments={"extensionId": e.id})
     r.revise(arguments={"extensionId": 0})
     res = api_client.delete(f"/api/v3/extension/{e.id}/")
     assert res.status_code == 204
     assert Extension.objects.count() == 0
开发者ID:rehandalal,项目名称:normandy,代码行数:11,代码来源:test_api.py

示例7: test_history

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import revise [as 别名]
        def test_history(self, api_client):
            recipe = RecipeFactory(name="version 1")
            recipe.revise(name="version 2")
            recipe.revise(name="version 3")

            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:rehandalal,项目名称:normandy,代码行数:12,代码来源:test_api.py

示例8: test_signature_is_cleared_if_autograph_unavailable

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import revise [as 别名]
    def test_signature_is_cleared_if_autograph_unavailable(self, mocker):
        # Mock the Autographer to return an error
        mock_autograph = mocker.patch("normandy.recipes.models.Autographer")
        mock_autograph.side_effect = ImproperlyConfigured

        recipe = RecipeFactory(name="unchanged", signed=True)
        original_signature = recipe.signature
        recipe.revise(name="changed")
        assert recipe.name == "changed"
        assert recipe.signature is not original_signature
        assert recipe.signature is None
开发者ID:rehandalal,项目名称:normandy,代码行数:13,代码来源:test_models.py

示例9: test_signature_is_updated_if_autograph_available

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import revise [as 别名]
    def test_signature_is_updated_if_autograph_available(self, mocked_autograph):
        recipe = RecipeFactory(name="unchanged", approver=UserFactory(), enabler=UserFactory())
        original_signature = recipe.signature
        assert original_signature is not None

        recipe.revise(name="changed")

        assert recipe.latest_revision.name == "changed"
        assert recipe.signature is not original_signature
        expected_sig = fake_sign([recipe.canonical_json()])[0]["signature"]
        assert recipe.signature.signature == expected_sig
开发者ID:rehandalal,项目名称:normandy,代码行数:13,代码来源:test_models.py

示例10: test_unique_name_update_collision

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import revise [as 别名]
        def test_unique_name_update_collision(self):
            action = ActionFactory(name="opt-out-study")
            arguments_a = {"name": "foo"}
            arguments_b = {"name": "bar"}
            RecipeFactory(action=action, arguments=arguments_a)
            recipe = RecipeFactory(action=action, arguments=arguments_b)

            with pytest.raises(serializers.ValidationError) as exc_info1:
                recipe.revise(arguments=arguments_a)
            error = action.errors["duplicate_study_name"]
            assert exc_info1.value.detail == {"arguments": {"name": error}}
开发者ID:rehandalal,项目名称:normandy,代码行数:13,代码来源:test_models.py

示例11: test_unique_experiment_slug_update_collision

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import revise [as 别名]
        def test_unique_experiment_slug_update_collision(self):
            action = ActionFactory(name="preference-experiment")
            arguments_a = {"slug": "a", "branches": []}
            arguments_b = {"slug": "b", "branches": []}
            # Does not throw when saving revisions
            RecipeFactory(action=action, arguments=arguments_a)
            recipe = RecipeFactory(action=action, arguments=arguments_b)

            with pytest.raises(serializers.ValidationError) as exc_info1:
                recipe.revise(arguments=arguments_a)
            error = action.errors["duplicate_experiment_slug"]
            assert exc_info1.value.detail == {"arguments": {"slug": error}}
开发者ID:rehandalal,项目名称:normandy,代码行数:14,代码来源:test_models.py

示例12: test_recipe_is_approved

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import revise [as 别名]
    def test_recipe_is_approved(self):
        recipe = RecipeFactory(name="old")
        assert not recipe.is_approved

        approval = ApprovalRequestFactory(revision=recipe.latest_revision)
        approval.approve(UserFactory(), "r+")
        assert recipe.is_approved
        assert recipe.approved_revision == recipe.latest_revision

        recipe.revise(name="new")
        assert recipe.is_approved
        assert recipe.approved_revision != recipe.latest_revision
开发者ID:rehandalal,项目名称:normandy,代码行数:14,代码来源:test_models.py

示例13: test_it_publishes_new_revisions_if_enabled

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import revise [as 别名]
    def test_it_publishes_new_revisions_if_enabled(self, mocked_remotesettings):
        recipe = RecipeFactory(name="Test", approver=UserFactory(), enabler=UserFactory())
        assert mocked_remotesettings.return_value.publish.call_count == 1

        recipe.revise(name="Modified")
        approval_request = recipe.latest_revision.request_approval(creator=UserFactory())
        approval_request.approve(approver=UserFactory(), comment="r+")

        assert mocked_remotesettings.return_value.publish.call_count == 2
        second_call_args, _ = mocked_remotesettings.return_value.publish.call_args_list[1]
        modified_recipe, = second_call_args
        assert modified_recipe.name == "Modified"
开发者ID:rehandalal,项目名称:normandy,代码行数:14,代码来源:test_models.py

示例14: test_disable

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import revise [as 别名]
    def test_disable(self):
        recipe = RecipeFactory(name="Test", approver=UserFactory(), enabler=UserFactory())
        assert recipe.enabled

        recipe.approved_revision.disable(user=UserFactory())
        assert not recipe.enabled

        with pytest.raises(EnabledState.NotActionable):
            recipe.approved_revision.disable(user=UserFactory())

        recipe.revise(name="New name")

        with pytest.raises(EnabledState.NotActionable):
            recipe.latest_revision.disable(user=UserFactory())
开发者ID:rehandalal,项目名称:normandy,代码行数:16,代码来源:test_models.py

示例15: test_recipe_revise_partial

# 需要导入模块: from normandy.recipes.tests import RecipeFactory [as 别名]
# 或者: from normandy.recipes.tests.RecipeFactory import revise [as 别名]
 def test_recipe_revise_partial(self):
     a1 = ActionFactory()
     recipe = RecipeFactory(
         name="unchanged",
         action=a1,
         arguments={"message": "something"},
         extra_filter_expression="something !== undefined",
         filter_object_json=None,
     )
     a2 = ActionFactory()
     recipe.revise(name="changed", action=a2)
     assert recipe.action == a2
     assert recipe.name == "changed"
     assert recipe.arguments == {"message": "something"}
     assert recipe.filter_expression == "something !== undefined"
开发者ID:rehandalal,项目名称:normandy,代码行数:17,代码来源:test_models.py


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