Write unit tests for this function.

"""Account settings view — handles profile reads/updates for the dashboard."""
import json


class AccountSettingsView:
    """store is dict-like: user_id -> profile dict."""

    def __init__(self, store):
        self.store = store

    def get(self, request):
        user_id = request.params.get("user_id")
        profile = self.store[user_id]
        return {"status": 200, "body": profile}

    def post(self, request):
        body = json.loads(request.body)
        user_id = body["user_id"]
        if user_id in self.store:
            return {"status": 409, "body": {"error": "exists"}}
        if len(body.get("display_name", "")) > 64:
            return {"status": 400, "body": {"error": "name too long"}}
        self.store[user_id] = {
            "display_name": body.get("display_name", ""),
            "email": body["email"],
            "notifications": body.get("notifications", True),
        }
        return {"status": 201, "body": self.store[user_id]}

    def put(self, request):
        body = json.loads(request.body)
        user_id = body["user_id"]
        profile = self.store.get(user_id, {})
        profile.update(body)
        self.store[user_id] = profile
        return {"status": 200, "body": profile}

    def delete(self, request):
        user_id = request.params.get("user_id")
        del self.store[user_id]
        return {"status": 204, "body": None}

    def patch(self, request):
        body = json.loads(request.body)
        user_id = body["user_id"]
        if "email" in body and "@" not in body["email"]:
            return {"status": 400, "body": {"error": "bad email"}}
        self.store[user_id].update(body)
        return {"status": 200, "body": self.store[user_id]}

    def options(self, request):
        return {"status": 200, "body": {"methods": ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"]}}
