Exemple #1
0
    def test_get_category_by_user_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_categories = Category.getCategoriesByUserId(user.user_id)
        assert result_categories[0] == category
 def getCategoriesByUserId(uid):
     try:
         categories = Category.getCategoriesByUserId(uid)
         result_list = []
         for category in categories:
             result_list.append(to_dict(category))
         result = {
             "message": "Success!",
             "categories": result_list
         }
         return jsonify(result), HttpStatus.OK
     except Exception as e:
         return jsonify(reason="Server error", error=e.__str__()), HttpStatus.INTERNAL_SERVER_ERROR # pragma: no mutate