# Path: api/models.py
# class ApiClient(AbstractApplication):
#     """
#     This is our custom 'Application' model for Oauth authentication.
#     """
# 
#     agree_tos = models.BooleanField(default=False)
#     password_grant_is_allowed = models.BooleanField(default=False)  # Enable password grant in OAuth2 authentication
#     created = models.DateTimeField(auto_now_add=True)
#     #  Add more custom fields here like description, logo, preferred services...
# 
#     def get_absolute_url(self):
#         return reverse('developers-app-detail', args=[self.id])
# 
#     def clean(self):
#         """
#         The AbstractApplication model includes a clean method that raises a ValidationError
#         if the redirect_uri is empty and is required by the authorization_grant_type. We have
#         implemented a custom version of this check (with a custom message) in api.forms.ApiClientForm
#         therefore we don't need model's clean method to do anything.
#         """
#         pass
# 
# 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 api.models import ApiClient
from accounts.models import Account
from django.core.urlresolvers import reverse
from services import management
from django.conf import settings
        from services.acservice.base import BaseACService
        from services.acservice.download import ACDownloadMixin
import oauth2_provider
import datetime


class OAuth2TestCase(TestCase):

    def setUp(self):

        # Create users
        self.dev_user = Account.objects.create_user('dev', password='devpass')
        self.end_user_password = 'endpass'
        self.end_user = Account.objects.create_user('end', password=self.end_user_password)

        # Create clients

# Path: api/models.py
# class ApiClient(AbstractApplication):
#     """
#     This is our custom 'Application' model for Oauth authentication.
#     """
# 
#     agree_tos = models.BooleanField(default=False)
#     password_grant_is_allowed = models.BooleanField(default=False)  # Enable password grant in OAuth2 authentication
#     created = models.DateTimeField(auto_now_add=True)
#     #  Add more custom fields here like description, logo, preferred services...
# 
#     def get_absolute_url(self):
#         return reverse('developers-app-detail', args=[self.id])
# 
#     def clean(self):
#         """
#         The AbstractApplication model includes a clean method that raises a ValidationError
#         if the redirect_uri is empty and is required by the authorization_grant_type. We have
#         implemented a custom version of this check (with a custom message) in api.forms.ApiClientForm
#         therefore we don't need model's clean method to do anything.
#         """
#         pass
# 
# 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: api/tests.py
from django.test import TestCase, override_settings
from api.models import ApiClient
from accounts.models import Account
from django.core.urlresolvers import reverse
from services import management
from django.conf import settings
        from services.acservice.base import BaseACService
        from services.acservice.download import ACDownloadMixin
import oauth2_provider
import datetime



class OAuth2TestCase(TestCase):

    def setUp(self):

        # Create users
        self.dev_user = Account.objects.create_user('dev', password='devpass')
        self.end_user_password = 'endpass'
        self.end_user = Account.objects.create_user('end', password=self.end_user_password)

        # Create clients

        ApiClient.objects.create(