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


Python tests.RecipeFactory类代码示例

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


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


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