# Path: signup/models.py
# def create_signup( email, questions ):
# def update_signup( email, questions ):
# def create_or_update_signup( email, questions ):
# def delete_signup( email, sequence ):
# def _signup2json( signup_db ):
# def get_signup( email, sequence ):
# def get_all_user_signups( email ):
# def get_signup_by_invite_code( invite_code ):
# def get_signups( sequence ):
# def get_signups_for_archiving( sequence ):
# def get_new_signups( ):
# def handle_new_signups( ):
# def add_user_to_global_list( email, sequence ):
# 
# Path: classphoto/models.py
# def _bio2dict( bio_db ):
# def save_bio( email, sequence, name, bio, avatar, twitter=None, gplus=None):
# def has_bio( email, sequence ):
# def get_bio( email ):
# def get_bios( sequence, limit=100 ):
# def get_bios_by_email( sequence, emails ):


from django.test import TestCase
from django.test.client import Client
from mock import patch
from signup import models as signup_api
from classphoto import models as classphoto_api


    def test_signed_up_not_signed_in_bio_save(self):
        signup_api.create_signup(**self.SIGNUP_DATA)
        c = Client()
        resp = c.post('/classphoto/1/save_bio/', self.BIO_DATA)
        self.assertRedirects(resp, '/classphoto/1/')
        bios = classphoto_api.get_bios(1)
        self.assertEquals(len(bios), 0)


    @patch('classphoto.emails.mailgun.api.send_email')
    def test_request_user_link(self, patcher):
        signup = signup_api.create_signup(**self.SIGNUP_DATA)
        c = Client()
        resp = c.post('/classphoto/request_link/', self.BIO_DATA, follow=True)
        self.assertRedirects(resp, '/classphoto/1/')
        self.assertTrue(patcher.called)
    

    def test_signed_in(self):
        signup = signup_api.create_signup(**self.SIGNUP_DATA)
        c = Client()
        resp = c.get('/classphoto/1/?key={0}'.format(signup['key']))
        session = c.session
        self.assertEquals(session['user_email'], self.BIO_DATA['email'])
        self.assertRedirects(resp, '/classphoto/1/')
    

    def test_signed_up_signed_in_bio_save(self):

# Path: signup/models.py
# def create_signup( email, questions ):
# def update_signup( email, questions ):
# def create_or_update_signup( email, questions ):
# def delete_signup( email, sequence ):
# def _signup2json( signup_db ):
# def get_signup( email, sequence ):
# def get_all_user_signups( email ):
# def get_signup_by_invite_code( invite_code ):
# def get_signups( sequence ):
# def get_signups_for_archiving( sequence ):
# def get_new_signups( ):
# def handle_new_signups( ):
# def add_user_to_global_list( email, sequence ):
# 
# Path: classphoto/models.py
# def _bio2dict( bio_db ):
# def save_bio( email, sequence, name, bio, avatar, twitter=None, gplus=None):
# def has_bio( email, sequence ):
# def get_bio( email ):
# def get_bios( sequence, limit=100 ):
# def get_bios_by_email( sequence, emails ):


# Path: classphoto/tests/test_view.py
from django.test import TestCase
from django.test.client import Client
from mock import patch
from signup import models as signup_api
from classphoto import models as classphoto_api



    def test_signed_up_not_signed_in_bio_save(self):
        signup_api.create_signup(**self.SIGNUP_DATA)
        c = Client()
        resp = c.post('/classphoto/1/save_bio/', self.BIO_DATA)
        self.assertRedirects(resp, '/classphoto/1/')
        bios = classphoto_api.get_bios(1)
        self.assertEquals(len(bios), 0)


    @patch('classphoto.emails.mailgun.api.send_email')
    def test_request_user_link(self, patcher):
        signup = signup_api.create_signup(**self.SIGNUP_DATA)
        c = Client()
        resp = c.post('/classphoto/request_link/', self.BIO_DATA, follow=True)
        self.assertRedirects(resp, '/classphoto/1/')
        self.assertTrue(patcher.called)
    

    def test_signed_in(self):
        signup = signup_api.create_signup(**self.SIGNUP_DATA)
        c = Client()
        resp = c.get('/classphoto/1/?key={0}'.format(signup['key']))
        session = c.session
        self.assertEquals(session['user_email'], self.BIO_DATA['email'])
        self.assertRedirects(resp, '/classphoto/1/')
    

    def test_signed_up_signed_in_bio_save(self):

        signup = signup_api.create_signup(**self.SIGNUP_DATA)