def test_it_works(self, rf): recipe = RecipeFactory(arguments={"foo": "bar"}) approval = ApprovalRequestFactory(revision=recipe.latest_revision) action = recipe.action serializer = RecipeSerializer(recipe, context={"request": rf.get("/")}) assert serializer.data == { "name": recipe.name, "id": recipe.id, "last_updated": Whatever(), "enabled": recipe.enabled, "extra_filter_expression": recipe.extra_filter_expression, "filter_expression": recipe.filter_expression, "revision_id": recipe.revision_id, "action": action.name, "arguments": {"foo": "bar"}, "is_approved": False, "latest_revision_id": recipe.latest_revision.id, "approved_revision_id": None, "approval_request": { "id": approval.id, "created": Whatever(), "creator": Whatever(), "approved": None, "approver": None, "comment": None, }, "identicon_seed": Whatever.startswith("v1:"), }
def test_recipe_as_remotesettings_record(self, mocked_autograph): """Test that recipes are serialized as expected by our clients.""" recipe = RecipeFactory(name="Test", approver=UserFactory(), enabler=UserFactory(), signed=True) record = exports.recipe_as_record(recipe) assert record == { "id": str(recipe.id), "recipe": { "action": recipe.action.name, "arguments": recipe.arguments, "filter_expression": recipe.filter_expression, "id": recipe.id, "name": recipe.name, "revision_id": str(recipe.revision_id), }, "signature": { "public_key": Whatever.regex(r"[a-zA-Z0-9/+]{160}"), "signature": Whatever.regex(r"[a-f0-9]{40}"), "timestamp": Whatever.iso8601(), "x5u": Whatever.startswith("https://"), }, }
def test_it_works(self, rf): recipe = RecipeFactory(arguments={"foo": "bar"}) approval = ApprovalRequestFactory(revision=recipe.latest_revision) action = recipe.action serializer = RecipeSerializer(recipe, context={"request": rf.get("/")}) assert serializer.data == { "name": recipe.name, "id": recipe.id, "last_updated": Whatever(), "enabled": recipe.enabled, "extra_filter_expression": recipe.extra_filter_expression, "filter_expression": recipe.filter_expression, "revision_id": recipe.revision_id, "action": action.name, "arguments": { "foo": "bar" }, "is_approved": False, "latest_revision_id": recipe.latest_revision.id, "approved_revision_id": None, "approval_request": { "id": approval.id, "created": Whatever(), "creator": Whatever(), "approved": None, "approver": None, "comment": None, }, "identicon_seed": Whatever.startswith("v1:"), "capabilities": sorted(recipe.capabilities), }
def test_it_works(self): signature = SignatureFactory() serializer = SignatureSerializer(instance=signature) assert serializer.data == { "signature": Whatever.regex(r"[a-f0-9]{40}"), "x5u": Whatever.startswith(signature.x5u), "timestamp": Whatever.iso8601(), "public_key": Whatever.regex(r"[a-zA-Z0-9/+]{160}"), }
def test_it_works(self): signature = SignatureFactory() serializer = SignatureSerializer(instance=signature) assert serializer.data == { 'signature': Whatever.regex(r'[a-f0-9]{40}'), 'x5u': Whatever.startswith(signature.x5u), 'timestamp': Whatever.iso8601(), 'public_key': Whatever.regex(r'[a-zA-Z0-9/+]{160}') }
def test_it_works(self): signature = SignatureFactory() serializer = SignatureSerializer(instance=signature) assert serializer.data == { "signature": Whatever.regex(r"[a-f0-9]{40}"), "x5u": Whatever.startswith(signature.x5u), "timestamp": Whatever.iso8601(), "public_key": Whatever.regex(r"[a-zA-Z0-9/+]{160}"), }
def test_it_works(self, rf): channel = ChannelFactory() country = CountryFactory() locale = LocaleFactory() recipe = RecipeFactory(arguments={'foo': 'bar'}, channels=[channel], countries=[country], locales=[locale]) approval = ApprovalRequestFactory(revision=recipe.latest_revision) action = recipe.action serializer = RecipeSerializer(recipe, context={'request': rf.get('/')}) assert serializer.data == { 'name': recipe.name, 'id': recipe.id, 'last_updated': Whatever(), 'enabled': recipe.enabled, 'extra_filter_expression': recipe.extra_filter_expression, 'filter_expression': recipe.filter_expression, 'revision_id': recipe.revision_id, 'action': action.name, 'arguments': { 'foo': 'bar', }, 'channels': [channel.slug], 'countries': [country.code], 'locales': [locale.code], 'is_approved': False, 'latest_revision_id': recipe.latest_revision.id, 'approved_revision_id': recipe.approved_revision_id, 'approval_request': { 'id': approval.id, 'created': Whatever(), 'creator': Whatever(), 'approved': None, 'approver': None, 'comment': None, }, 'identicon_seed': Whatever.startswith('v1:'), }
def test_it_works(self, rf): recipe = RecipeFactory(arguments={"foo": "bar"}, filter_object_json=None) approval = ApprovalRequestFactory(revision=recipe.latest_revision) action = recipe.action serializer = RecipeSerializer(recipe, context={"request": rf.get("/")}) assert serializer.data == { "name": recipe.name, "id": recipe.id, "last_updated": Whatever(), "enabled": recipe.enabled, "extra_filter_expression": recipe.extra_filter_expression, "filter_expression": recipe.filter_expression, "filter_object": [], "action": { "arguments_schema": {}, "id": action.id, "implementation_url": Whatever(), "name": action.name, }, "arguments": { "foo": "bar" }, "is_approved": False, "latest_revision": RecipeRevisionSerializer(recipe.latest_revision).data, "approved_revision": None, "approval_request": { "id": approval.id, "created": Whatever(), "creator": Whatever(), "approved": None, "approver": None, "comment": None, }, "identicon_seed": Whatever.startswith("v1:"), }