Пример #1
0
    def test_get_category_by_id(self):
        userData = {'email': 'test', 'password': '******', 'username': '******'}
        user = User(**userData).create()

        categoryData = {'user_id': user.user_id, 'name': 'test_category'}
        category = Category(**categoryData).create()
        result_category = Category.getCategoryById(category.category_id)
        assert result_category == category
 def getCategoryById(cid):
     try:
         category = Category.getCategoryById(cid)
         category_dict = to_dict(category)
         result = {
             "message": "Success!",
             "category": category_dict
         }
         return jsonify(result), HttpStatus.OK
     except Exception as e:
         return jsonify(reason="Server error", error=e.__str__()), HttpStatus.INTERNAL_SERVER_ERROR