def test_new_category(app, authed_client): category = ForumCategory.new(name='NewCategory', description=None, position=100) assert category.name == 'NewCategory' assert category.description is None assert category.position == 100 assert ForumCategory.from_cache(category.cache_key).id == category.id == 6
def add_category(name: str, description: str = None, position: int = 0) -> flask.Response: """ This is the endpoint for forum category creation. The ``forums_forums_modify`` permission is required to access this endpoint. .. :quickref: ForumCategory; Create a forum category. **Example request**: .. parsed-literal:: POST /forums/categories HTTP/1.1 { "name": "Support", "description": "The place for confused share bears.", "position": 6 } **Example response**: .. parsed-literal:: { "status": "success", "response": "<ForumCategory>" } :>json dict response: The newly created forum category :statuscode 200: Creation successful :statuscode 400: Creation unsuccessful """ category = ForumCategory.new(name=name, description=description, position=position) return flask.jsonify(category)