import unittest
from unittest import TestCase
from user import User
from bucketlist import BucketList
from flask import url_for, session

from app import app


class BucketListTest(TestCase):
    def setUp(self):        
        app.config['SECRET_KEY'] = 'seasasaskrit!'
        # creates a test client
        self.client = app.test_client()
        
        self.client.testing = True

    def test_success(self):
        # sends HTTP GET request to the application
        # on the specified path
        result = self.client.get('/login')
        self.assertEqual(result.status_code, 200)

    def test_failure(self):
        # sends HTTP GET request to the application
        # on the specified path
        result = self.client.get('/nonexistant.html')
        self.assertEqual(result.status_code, 404)
    
    def test_login_page_loads(self):
        # assert login page loads correctly
        result = self.client.get('/login')
        self.assertTrue(b'The best way to keep track of your dreams and goals' in result.data)

    def test_sign_page_posts_and_redirects(self):
        result = self.client.post('signup', data={
            'username': 'hermano',
            'email': 'herm@email.com',
            'password': 'hard',
            'confirm_password': 'hard'
        })
        self.assertTrue(result.status_code == 302)

    

if __name__ == '__main__':
    unittest.main()

@@ -150,16 +150,23 @@
 port app
+, users
 %0A%0A%0Aclass
@@ -1345,16 +1345,688 @@
 = 302)%0A%0A
+    def test_signup_redirects_to_managelist(self):%0A        result = self.client.post('signup', data=%7B%0A            'username': 'hermano',%0A            'email': 'herm@email.com',%0A            'password': 'hard',%0A            'confirm_password': 'hard'%0A        %7D, follow_redirects = True)%0A        self.assertIn(b'My Bucket Lists', result.data)%0A%0A    def test_login_page_posts_and_redirects(self):%0A        user = User('hermano', 'herm@email.com', 'hard')%0A        users%5B'herm@email.com'%5D = user%0A%0A        result = self.client.post('login', data=%7B%0A            'username': 'hermano',%0A            'password': 'hard'%0A        %7D)%0A        self.assertTrue(result.status_code == 302)%0A%0A    %0A%0A
     %0A%0Aif

Add test for login success