# Path: tests/factories.py
# class ProjectFactory(factory.DjangoModelFactory):
#     title = factory.Sequence(lambda n: 'Testproject %s' % n)
#     slug = factory.Sequence(lambda n: 'test%s' % n)
#     goal = 200.00
#     currency = 'CHF'
#     start = timezone.now()
#     end = timezone.now() + timedelta(days=1)
# 
#     class Meta:
#         model = Project
# 
# class RewardFactory(factory.DjangoModelFactory):
#     description = factory.Sequence(lambda n: 'testreward%s' % n)
# 
#     class Meta:
#         model = Reward
# 
# class UserFactory(factory.DjangoModelFactory):
#     username = factory.Sequence(lambda n: 'user%s' % n)
#     email = factory.Sequence(lambda n: 'user%s@example.org' % n)
#     is_active = True
#     is_superuser = False
#     is_staff = False
#     # password 'test'
#     password = 'pbkdf2_sha256$10000$s9Ed0KfEQgTY$CsbbUpXaWk+8eAB+Oga2hBqD82kU4vl+QQaqr/wCZXY='
#     first_name = 'Hans'
#     last_name = 'Muster'
# 
#     class Meta:
#         model = get_user_model()
# 
# Path: zipfelchappe/app_settings.py
# CURRENCIES = getattr(settings, 'ZIPFELCHAPPE_CURRENCIES', ('CHF', 'EUR', 'USD'))
# DISQUS_SHORTNAME = getattr(settings, 'ZIPFELCHAPPE_DISQUS_SHORTNAME', None)
# PAGINATE_BY = getattr(settings, 'ZIPFELCHAPPE_PAGINATE_BY', 10)
# PAGINATE_BACKERS_BY = getattr(settings, 'ZIPFELCHAPPE_PAGINATE_BACKERS', 25)
# ALLOW_ANONYMOUS_PLEDGES = getattr(settings, 'ZIPFELCHAPPE_ALLOW_ANONYMOUS_PLEDGES', True)
# BACKER_PROFILE = getattr(settings, 'ZIPFELCHAPPE_BACKER_PROFILE', None)
# ROOT_URLS = getattr(settings, 'ZIPFELCHAPPE_URLS', 'zipfelchappe.urls')
# DEFAULT_IMAGE_URL = getattr(settings, 'ZIPFELCHAPPE_PLACEHOLDER_IMAGE_URL', '')
# USER_FIRST_NAME_FIELD = getattr(
#     settings, 'ZIPFELCHAPPE_USER_FIRST_NAME_FIELD', 'first_name')
# USER_LAST_NAME_FIELD = getattr(
#     settings, 'ZIPFELCHAPPE_USER_LAST_NAME_FIELD', 'last_name')
# USER_EMAIL_FIELD = getattr(
#     settings, 'ZIPFELCHAPPE_USER_EMAIL_FIELD', 'email')
# MAX_PROJECT_DURATION_DAYS = getattr(settings, 'ZIPFELCHAPPE_MAX_PROJECT_DURATION', 120)
# TERMS_URL = settings.ZIPFELCHAPPE_TERMS_URL
# MANAGERS = getattr(settings, 'ZIPFELCHAPPE_MANAGERS', settings.MANAGERS)


from django.core import mail
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.client import Client
from django.contrib.auth.tests.utils import skipIfCustomUser
from feincms.module.page.models import Page
from feincms.content.application.models import ApplicationContent, app_reverse
from tests.factories import ProjectFactory, RewardFactory, UserFactory
from zipfelchappe import app_settings
from __future__ import absolute_import, unicode_literals



@skipIfCustomUser
class PledgeWorkflowTest(TestCase):
    login_url = '/accounts/login/'

    def setUp(self):
        # feincms page containing zipfelchappe app content
        self.page = Page.objects.create(title='Projects', slug='projects')
        ct = self.page.content_type_for(ApplicationContent)
        ct.objects.create(parent=self.page, urlconf_path=app_settings.ROOT_URLS)

        # Fixture Data for following tests
        self.project1 = ProjectFactory.create()

# Path: tests/factories.py
# class ProjectFactory(factory.DjangoModelFactory):
#     title = factory.Sequence(lambda n: 'Testproject %s' % n)
#     slug = factory.Sequence(lambda n: 'test%s' % n)
#     goal = 200.00
#     currency = 'CHF'
#     start = timezone.now()
#     end = timezone.now() + timedelta(days=1)
# 
#     class Meta:
#         model = Project
# 
# class RewardFactory(factory.DjangoModelFactory):
#     description = factory.Sequence(lambda n: 'testreward%s' % n)
# 
#     class Meta:
#         model = Reward
# 
# class UserFactory(factory.DjangoModelFactory):
#     username = factory.Sequence(lambda n: 'user%s' % n)
#     email = factory.Sequence(lambda n: 'user%s@example.org' % n)
#     is_active = True
#     is_superuser = False
#     is_staff = False
#     # password 'test'
#     password = 'pbkdf2_sha256$10000$s9Ed0KfEQgTY$CsbbUpXaWk+8eAB+Oga2hBqD82kU4vl+QQaqr/wCZXY='
#     first_name = 'Hans'
#     last_name = 'Muster'
# 
#     class Meta:
#         model = get_user_model()
# 
# Path: zipfelchappe/app_settings.py
# CURRENCIES = getattr(settings, 'ZIPFELCHAPPE_CURRENCIES', ('CHF', 'EUR', 'USD'))
# DISQUS_SHORTNAME = getattr(settings, 'ZIPFELCHAPPE_DISQUS_SHORTNAME', None)
# PAGINATE_BY = getattr(settings, 'ZIPFELCHAPPE_PAGINATE_BY', 10)
# PAGINATE_BACKERS_BY = getattr(settings, 'ZIPFELCHAPPE_PAGINATE_BACKERS', 25)
# ALLOW_ANONYMOUS_PLEDGES = getattr(settings, 'ZIPFELCHAPPE_ALLOW_ANONYMOUS_PLEDGES', True)
# BACKER_PROFILE = getattr(settings, 'ZIPFELCHAPPE_BACKER_PROFILE', None)
# ROOT_URLS = getattr(settings, 'ZIPFELCHAPPE_URLS', 'zipfelchappe.urls')
# DEFAULT_IMAGE_URL = getattr(settings, 'ZIPFELCHAPPE_PLACEHOLDER_IMAGE_URL', '')
# USER_FIRST_NAME_FIELD = getattr(
#     settings, 'ZIPFELCHAPPE_USER_FIRST_NAME_FIELD', 'first_name')
# USER_LAST_NAME_FIELD = getattr(
#     settings, 'ZIPFELCHAPPE_USER_LAST_NAME_FIELD', 'last_name')
# USER_EMAIL_FIELD = getattr(
#     settings, 'ZIPFELCHAPPE_USER_EMAIL_FIELD', 'email')
# MAX_PROJECT_DURATION_DAYS = getattr(settings, 'ZIPFELCHAPPE_MAX_PROJECT_DURATION', 120)
# TERMS_URL = settings.ZIPFELCHAPPE_TERMS_URL
# MANAGERS = getattr(settings, 'ZIPFELCHAPPE_MANAGERS', settings.MANAGERS)


# Path: tests/test_flow.py
from django.core import mail
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.client import Client
from django.contrib.auth.tests.utils import skipIfCustomUser
from feincms.module.page.models import Page
from feincms.content.application.models import ApplicationContent, app_reverse
from tests.factories import ProjectFactory, RewardFactory, UserFactory
from zipfelchappe import app_settings

from __future__ import absolute_import, unicode_literals



@skipIfCustomUser
class PledgeWorkflowTest(TestCase):
    login_url = '/accounts/login/'

    def setUp(self):
        # feincms page containing zipfelchappe app content
        self.page = Page.objects.create(title='Projects', slug='projects')
        ct = self.page.content_type_for(ApplicationContent)
        ct.objects.create(parent=self.page, urlconf_path=app_settings.ROOT_URLS)

        # Fixture Data for following tests
        self.project1 = ProjectFactory.create()

        self.project2 = ProjectFactory.create()