• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tests.RecipeFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_signatures_update_correctly_on_enable

    def test_signatures_update_correctly_on_enable(self, mocked_autograph):
        recipe = RecipeFactory(signed=False, approver=UserFactory())
        recipe.approved_revision.enable(user=UserFactory())
        recipe.refresh_from_db()

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


示例2: test_filter_by_sample_rate

    def test_filter_by_sample_rate(self):
        always_match = RecipeFactory(sample_rate=1.0)
        never_match = RecipeFactory(sample_rate=0.0)
        client = ClientFactory()

        assert always_match.matches(client)
        assert not never_match.matches(client)
开发者ID:MFBrewster,项目名称:normandy,代码行数:7,代码来源:test_models.py


示例3: test_filter_exclude_many

    def test_filter_exclude_many(self):
        locale_match1, locale_match2, locale_not = LocaleFactory.create_batch(3)
        recipe = RecipeFactory(locales=[locale_match1, locale_match2])
        client = ClientFactory(locale=locale_not.code)

        assert not recipe.matches(client)
        assert recipe.matches(client, exclude=[get_locales])
开发者ID:MFBrewster,项目名称:normandy,代码行数:7,代码来源:test_models.py


示例4: test_canonical_json

 def test_canonical_json(self):
     recipe = RecipeFactory(
         action=ActionFactory(name="action"),
         arguments_json='{"foo": 1, "bar": 2}',
         extra_filter_expression="2 + 2 == 4",
         name="canonical",
         filter_object_json=None,
     )
     # Yes, this is really ugly, but we really do need to compare an exact
     # byte sequence, since this is used for hashing and signing
     filter_expression = "2 + 2 == 4"
     expected = (
         "{"
         '"action":"action",'
         '"arguments":{"bar":2,"foo":1},'
         '"filter_expression":"%(filter_expression)s",'
         '"id":%(id)s,'
         '"name":"canonical",'
         '"revision_id":"%(revision_id)s"'
         "}"
     ) % {
         "id": recipe.id,
         "revision_id": recipe.revision_id,
         "filter_expression": filter_expression,
     }
     expected = expected.encode()
     assert recipe.canonical_json() == expected
开发者ID:rehandalal,项目名称:normandy,代码行数:27,代码来源:test_models.py


示例5: test_cant_change_signature_and_other_fields

 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,代码行数:7,代码来源:test_models.py


示例6: test_delete_pending_approval_request_on_revise

    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,代码行数:7,代码来源:test_models.py


示例7: test_enabled_state_carried_over_on_approval

 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,代码行数:8,代码来源:test_models.py


示例8: test_recipe_doesnt_revise_when_clean

    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,代码行数:9,代码来源:test_models.py


示例9: test_filter_by_country_one

    def test_filter_by_country_one(self):
        country1 = CountryFactory()
        country2 = CountryFactory()
        recipe = RecipeFactory(countries=[country1])
        client1 = ClientFactory(country=country1.code)
        client2 = ClientFactory(country=country2.code)

        assert recipe.matches(client1)
        assert not recipe.matches(client2)
开发者ID:MFBrewster,项目名称:normandy,代码行数:9,代码来源:test_models.py


示例10: test_can_delete_extensions_no_longer_in_use

 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,代码行数:9,代码来源:test_api.py


示例11: test_filter_by_locale_one

    def test_filter_by_locale_one(self):
        locale1 = LocaleFactory()
        locale2 = LocaleFactory()
        recipe = RecipeFactory(locales=[locale1])
        client1 = ClientFactory(locale=locale1.code)
        client2 = ClientFactory(locale=locale2.code)

        assert recipe.matches(client1)
        assert not recipe.matches(client2)
开发者ID:MFBrewster,项目名称:normandy,代码行数:9,代码来源:test_models.py


示例12: test_filter_by_channel_one

    def test_filter_by_channel_one(self):
        beta = ReleaseChannelFactory(slug='beta')
        recipe = RecipeFactory(release_channels=[beta])

        release_client = ClientFactory(release_channel='release')
        beta_client = ClientFactory(release_channel='beta')

        assert not recipe.matches(release_client)
        assert recipe.matches(beta_client)
开发者ID:MFBrewster,项目名称:normandy,代码行数:9,代码来源:test_models.py


示例13: test_can_update_extensions_no_longer_in_use

 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,代码行数:9,代码来源:test_api.py


示例14: test_revision_id_increments

    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,代码行数:9,代码来源:test_models.py


示例15: test_history

        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,代码行数:10,代码来源:test_api.py


示例16: test_unique_name_update_collision

        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,代码行数:11,代码来源:test_models.py


示例17: test_signature_is_updated_if_autograph_available

    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,代码行数:11,代码来源:test_models.py


示例18: test_signature_is_cleared_if_autograph_unavailable

    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,代码行数:11,代码来源:test_models.py


示例19: test_signature_is_cleared_if_autograph_unavailable

    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,代码行数:12,代码来源:test_models.py


示例20: test_it_doesnt_disable_recipes

    def test_it_doesnt_disable_recipes(self, mock_action):
        recipe = RecipeFactory(
            action__name='test-action',
            action__implementation='old',
            enabled=True
        )
        action = recipe.action
        mock_action(action.name, 'impl', action.arguments_schema)

        call_command('update_actions')
        recipe.refresh_from_db()
        assert recipe.enabled
开发者ID:chartjes,项目名称:normandy,代码行数:12,代码来源:test_commands.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python dbutils.babel_values函数代码示例发布时间:2022-05-27
下一篇:
Python selector.MultiFieldSelector类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap