def test_it_works(self): author = UserFactory() reviewer = UserFactory() recipe = RecipeFactory(name="first", user=author) revision1 = recipe.latest_revision approval_request = revision1.request_approval(author) approval_request.approve(reviewer, "r+") revision1.enable(author) state1 = revision1.enabled_state assert state1 is not None recipe.revise("second", user=author) revision2 = recipe.latest_revision approval_request = revision2.request_approval(author) approval_request.approve(reviewer, "r+") state2 = revision2.enabled_state assert state2 is not None serializer = EnabledStateSerializer(state1) assert serializer.data == { "id": state1.id, "carryover_from": None, "created": Whatever.iso8601(), "creator": { "id": author.id, "first_name": author.first_name, "last_name": author.last_name, "email": author.email, }, "enabled": True, "revision_id": revision1.id, } serializer = EnabledStateSerializer(state2) assert serializer.data == { "id": state2.id, "carryover_from": state1.id, "created": Whatever.iso8601(), "creator": { "id": reviewer.id, "first_name": reviewer.first_name, "last_name": reviewer.last_name, "email": reviewer.email, }, "enabled": True, "revision_id": revision2.id, }
def test_it_works(self): author = UserFactory() reviewer = UserFactory() recipe = RecipeFactory(name="first", user=author) revision1 = recipe.latest_revision approval_request = revision1.request_approval(author) approval_request.approve(reviewer, "r+") revision1.enable(author) state1 = revision1.enabled_state assert state1 is not None recipe.revise("second", user=author) revision2 = recipe.latest_revision approval_request = revision2.request_approval(author) approval_request.approve(reviewer, "r+") state2 = revision2.enabled_state assert state2 is not None serializer = EnabledStateSerializer(state1) assert serializer.data == { "id": state1.id, "carryover_from": None, "created": Whatever.iso8601(), "creator": { "id": author.id, "first_name": author.first_name, "last_name": author.last_name, "email": author.email, }, "enabled": True, "revision_id": revision1.id, } serializer = EnabledStateSerializer(state2) assert serializer.data == { "id": state2.id, "carryover_from": state1.id, "created": Whatever.iso8601(), "creator": { "id": reviewer.id, "first_name": reviewer.first_name, "last_name": reviewer.last_name, "email": reviewer.email, }, "enabled": True, "revision_id": revision2.id, }
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): 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}"), }