# Path: accounts/models.py
# class Account(AbstractUser):
#     """
#     This is our custom 'User' model.
#     """
# 
#     is_developer = models.BooleanField(default=False, blank=False)
#     accepted_tos = models.BooleanField(default=False, blank=False)
#     #  Add more custom fields here like avatar...
# 
#     def send_activation_email(self):
#         tvars = {
#             'user': self,
#             'username': self.username,
#             'hash': create_hash(self.id)
#         }
#         send_mail(self.email, subject='Activate your Audio Commons user account',
#                   template='emails/account_activation.txt', context=tvars)
# 
#     class Meta:
#         verbose_name = _('account')
#         verbose_name_plural = _('accounts')


from django.test import TestCase, override_settings
from accounts.models import Account
from django.core.urlresolvers import reverse
from django.core import mail
from django.conf import settings


@override_settings(EMAIL_BACKEND='django.core.mail.backends.locmem.EmailBackend')
class AccountRegistrationTestCase(TestCase):

    def test_user_registration(self):

        # Register new account
        post_data = {
            'password1': '123456',
            'password2': '123456',
            'accepted_tos': 'on',
            'username': 'test_username',
            'email1': 'example@email.com',
            'email2': 'example@email.com',
        }
        resp = self.client.post(reverse('registration'), data=post_data)
        self.assertEquals(resp.status_code, 200)

        # Check that a user object has been created with that user name but it is still inactive

# Path: accounts/models.py
# class Account(AbstractUser):
#     """
#     This is our custom 'User' model.
#     """
# 
#     is_developer = models.BooleanField(default=False, blank=False)
#     accepted_tos = models.BooleanField(default=False, blank=False)
#     #  Add more custom fields here like avatar...
# 
#     def send_activation_email(self):
#         tvars = {
#             'user': self,
#             'username': self.username,
#             'hash': create_hash(self.id)
#         }
#         send_mail(self.email, subject='Activate your Audio Commons user account',
#                   template='emails/account_activation.txt', context=tvars)
# 
#     class Meta:
#         verbose_name = _('account')
#         verbose_name_plural = _('accounts')


# Path: accounts/tests.py
from django.test import TestCase, override_settings
from accounts.models import Account
from django.core.urlresolvers import reverse
from django.core import mail
from django.conf import settings



@override_settings(EMAIL_BACKEND='django.core.mail.backends.locmem.EmailBackend')
class AccountRegistrationTestCase(TestCase):

    def test_user_registration(self):

        # Register new account
        post_data = {
            'password1': '123456',
            'password2': '123456',
            'accepted_tos': 'on',
            'username': 'test_username',
            'email1': 'example@email.com',
            'email2': 'example@email.com',
        }
        resp = self.client.post(reverse('registration'), data=post_data)
        self.assertEquals(resp.status_code, 200)

        # Check that a user object has been created with that user name but it is still inactive

        account = Account.objects.get(username='test_username')