import os
from angel_tree import app, bcrypt
from angel_tree.mod_family.controllers import *
from angel_tree.mod_family.models import *
from angel_tree.mod_auth.models import User
from flask import url_for
from flask_login import current_user
from flask_principal import PermissionDenied
from .mod_auth_test import create_user
import unittest
import tempfile

from .mod_auth_test import create_user, _username, _password

class ModFamilytestCase(unittest.TestCase):
    def setUp(self):
        self.app = app.test_client()
        User.drop_collection()
        self.username = _username
        self.password = _password

    def test_family_index(self):
        create_user()

        with self.app:
            self.app.post('/auth/login', data=dict(
                email=_username,
                password=_password
            ), follow_redirects=False)

            result = self.app.get('/family')

            self.assertEqual(result.status_code, 200)

    def test_family_labels(self):
        create_user()

        with self.app:
            self.app.post('/auth/login', data=dict(
                email=_username,
                password=_password
            ), follow_redirects=False)

            result = self.app.get('/family/labels')

            self.assertEqual(result.status_code, 200)

    def tearDown(self):
        pass
