# Path: application/app.py
# def index():
# def any_root_path(path):
# def get_user():
# def create_user():
# def get_token():
# def is_token_valid():
# def get_balances():
# def get_balances_route():
# def get_accounts():
# def get_accounts_route():
# def create_account():
# def edit_account():
# def delete_account():
# def get_transactions():
# def get_future_transactions():
# def create_transaction():
# def edit_transaction():
# def tick_transaction():
# def delete_transaction():
# def get_recurring_groups():
# def generate_recurring(account_id, label, amount, start_date, end_date, recurring_group_id, recurrence_day, recurrence_month, future_only=False):
# def create_recurring_group():
# def edit_recurring_group():
# def delete_recurring_group():
# def get_charts():
# 
# Path: application/models.py
# class User(db.Model):
#     id = db.Column(db.Integer(), primary_key=True)
#     email = db.Column(db.String(255), unique=True)
#     password = db.Column(db.String(255))
# 
#     def __init__(self, email, password):
#         self.email = email
#         self.active = True
#         self.password = User.hashed_password(password)
# 
#     @staticmethod
#     def hashed_password(password):
#         return bcrypt.generate_password_hash(password)
# 
#     @staticmethod
#     def get_user_with_email_and_password(email, password):
#         user = User.query.filter_by(email=email).first()
#         if user and bcrypt.check_password_hash(user.password, password):
#             return user
#         else:
#             return None


from flask_testing import TestCase
from application.app import app, db
from application.models import User
from datetime import datetime
from setup import basedir
import os
import json
        with self.app.session_transaction() as sess:
            sess['user_id'] = 1
            sess['_fresh'] = True  # https://flask-login.readthedocs.org/en/latest/#fresh-logins

        # create account
        self.app.post(
            "/api/accounts/create",
            data=json.dumps(self.default_account),
            content_type='application/json',
            headers={'Authorization': self.token}
        )

        # create transaction
        self.app.post(
            "/api/transactions/create",
            data=json.dumps(self.default_transaction),
            content_type='application/json',
            headers={'Authorization': self.token}
        )

        # create recurring group
        self.app.post(
            "/api/recurring/create",
            data=json.dumps(self.default_recurring_group),
            content_type='application/json',
            headers={'Authorization': self.token}
        )

    def tearDown(self):
        db.session.remove()

# Path: application/app.py
# def index():
# def any_root_path(path):
# def get_user():
# def create_user():
# def get_token():
# def is_token_valid():
# def get_balances():
# def get_balances_route():
# def get_accounts():
# def get_accounts_route():
# def create_account():
# def edit_account():
# def delete_account():
# def get_transactions():
# def get_future_transactions():
# def create_transaction():
# def edit_transaction():
# def tick_transaction():
# def delete_transaction():
# def get_recurring_groups():
# def generate_recurring(account_id, label, amount, start_date, end_date, recurring_group_id, recurrence_day, recurrence_month, future_only=False):
# def create_recurring_group():
# def edit_recurring_group():
# def delete_recurring_group():
# def get_charts():
# 
# Path: application/models.py
# class User(db.Model):
#     id = db.Column(db.Integer(), primary_key=True)
#     email = db.Column(db.String(255), unique=True)
#     password = db.Column(db.String(255))
# 
#     def __init__(self, email, password):
#         self.email = email
#         self.active = True
#         self.password = User.hashed_password(password)
# 
#     @staticmethod
#     def hashed_password(password):
#         return bcrypt.generate_password_hash(password)
# 
#     @staticmethod
#     def get_user_with_email_and_password(email, password):
#         user = User.query.filter_by(email=email).first()
#         if user and bcrypt.check_password_hash(user.password, password):
#             return user
#         else:
#             return None


# Path: testing_config.py
from flask_testing import TestCase
from application.app import app, db
from application.models import User
from datetime import datetime
from setup import basedir
import os
import json

        with self.app.session_transaction() as sess:
            sess['user_id'] = 1
            sess['_fresh'] = True  # https://flask-login.readthedocs.org/en/latest/#fresh-logins

        # create account
        self.app.post(
            "/api/accounts/create",
            data=json.dumps(self.default_account),
            content_type='application/json',
            headers={'Authorization': self.token}
        )

        # create transaction
        self.app.post(
            "/api/transactions/create",
            data=json.dumps(self.default_transaction),
            content_type='application/json',
            headers={'Authorization': self.token}
        )

        # create recurring group
        self.app.post(
            "/api/recurring/create",
            data=json.dumps(self.default_recurring_group),
            content_type='application/json',
            headers={'Authorization': self.token}
        )

    def tearDown(self):
        db.session.remove()

        db.drop_all()