# Path: userprofiles/contrib/accountverification/models.py
# class AccountVerification(models.Model):
#     ACTIVATED = 'ALREADY_ACTIVATED'
# 
#     user = models.ForeignKey(User, unique=True, verbose_name=_('User'))
#     activation_key = models.CharField(_('Activation key'), max_length=40)
# 
#     objects = AccountVerificationManager()
# 
#     def __unicode__(self):
#         return u'Account verification: %s' % self.user
# 
#     def activation_key_expired(self):
#         expiration_date = timedelta(days=up_settings.ACCOUNT_VERIFICATION_DAYS)
#         return (self.activation_key == self.ACTIVATED
#             or (self.user.date_joined + expiration_date <= timezone.now()))
#     activation_key_expired.boolean = True
# 
#     class Meta:
#         app_label = 'userprofiles'
#         verbose_name = _('Account verification')
#         verbose_name_plural = _('Account verifications')
# 
# Path: userprofiles/settings.py
# class Settings(object):
#     def __init__(self, **kwargs):
#     def __getattr__(self, key):
# def validate_settings():


from datetime import timedelta
from django.contrib.auth.models import User
from django.test import TestCase
from userprofiles.contrib.accountverification.models import AccountVerification
from userprofiles.settings import up_settings




class ModelsTests(TestCase):
    def setUp(self):
        self.data = {
            'username': 'newuser',
            'email': 'newuser@example.com',
            'password': 'newuserpass',
        }

    def test_activate_user(self):
        user = AccountVerification.objects.create_inactive_user(
            self.data['username'], self.data['password'], self.data['email'])
        user.date_joined = user.date_joined - timedelta(
            days=up_settings.ACCOUNT_VERIFICATION_DAYS, seconds=1)
        user.save()

        verification = AccountVerification.objects.get(user=user)

        self.assertFalse(

# Path: userprofiles/contrib/accountverification/models.py
# class AccountVerification(models.Model):
#     ACTIVATED = 'ALREADY_ACTIVATED'
# 
#     user = models.ForeignKey(User, unique=True, verbose_name=_('User'))
#     activation_key = models.CharField(_('Activation key'), max_length=40)
# 
#     objects = AccountVerificationManager()
# 
#     def __unicode__(self):
#         return u'Account verification: %s' % self.user
# 
#     def activation_key_expired(self):
#         expiration_date = timedelta(days=up_settings.ACCOUNT_VERIFICATION_DAYS)
#         return (self.activation_key == self.ACTIVATED
#             or (self.user.date_joined + expiration_date <= timezone.now()))
#     activation_key_expired.boolean = True
# 
#     class Meta:
#         app_label = 'userprofiles'
#         verbose_name = _('Account verification')
#         verbose_name_plural = _('Account verifications')
# 
# Path: userprofiles/settings.py
# class Settings(object):
#     def __init__(self, **kwargs):
#     def __getattr__(self, key):
# def validate_settings():


# Path: userprofiles/contrib/accountverification/tests/test_models.py
from datetime import timedelta
from django.contrib.auth.models import User
from django.test import TestCase
from userprofiles.contrib.accountverification.models import AccountVerification
from userprofiles.settings import up_settings





class ModelsTests(TestCase):
    def setUp(self):
        self.data = {
            'username': 'newuser',
            'email': 'newuser@example.com',
            'password': 'newuserpass',
        }

    def test_activate_user(self):
        user = AccountVerification.objects.create_inactive_user(
            self.data['username'], self.data['password'], self.data['email'])
        user.date_joined = user.date_joined - timedelta(
            days=up_settings.ACCOUNT_VERIFICATION_DAYS, seconds=1)
        user.save()

        verification = AccountVerification.objects.get(user=user)

        self.assertFalse(

            AccountVerification.objects.activate_user('wrong-pattern-format'))