# Path: wiggum/applications/models.py
# class Application(models.Model):
#     """App representation"""
# 
#     name = models.CharField(_('Application name'),
#                             max_length=100,
#                             blank=False,
#                             null=False,
#                             unique=True)
#     token = models.CharField(_('Application token'),
#                              max_length=32,
#                              default=generate_api_key,
#                              blank=False,
#                              null=False,
#                              validators=[validators.RegexValidator(
#                                 r'^[a-fA-F0-9]{32}$',
#                                 _('Key should be hexadecimal and length 32')
#                                 ), ],
#                              unique=True)
#     description = models.TextField(_('Application description'),
#                                    blank=True,
#                                    null=False)
#     active = models.BooleanField(_('Application active'), default=True)
#     project_permissions = models.ManyToManyField(ProjectPermission,
#                                                  blank=True)
#     theme = models.CharField(_('App associated theme'),
#                              choices=THEMES,
#                              default=DEFAULT_THEME,
#                              max_length=50,)
# 
#     def __str__(self):
#         return "{0}({1})".format(self.name, self.token)
# 
# Path: wiggum/applications/utils.py
# def generate_api_key():
#     return uuid.uuid4().hex


from django.conf import settings
from django.test import TransactionTestCase
from django.db.utils import IntegrityError
from .models import Application
from users.models import ProjectPermission
from .utils import generate_api_key


class ApplicationModelTest(TransactionTestCase):
    def setUp(self):
        # Initial data
        self.data = [{
            'name': "Batman application",
            'token': generate_api_key(),
            'description': "Bruce Wayne awesome application",
            'active': True, }, {

            'name': "Spiderman application",

# Path: wiggum/applications/models.py
# class Application(models.Model):
#     """App representation"""
# 
#     name = models.CharField(_('Application name'),
#                             max_length=100,
#                             blank=False,
#                             null=False,
#                             unique=True)
#     token = models.CharField(_('Application token'),
#                              max_length=32,
#                              default=generate_api_key,
#                              blank=False,
#                              null=False,
#                              validators=[validators.RegexValidator(
#                                 r'^[a-fA-F0-9]{32}$',
#                                 _('Key should be hexadecimal and length 32')
#                                 ), ],
#                              unique=True)
#     description = models.TextField(_('Application description'),
#                                    blank=True,
#                                    null=False)
#     active = models.BooleanField(_('Application active'), default=True)
#     project_permissions = models.ManyToManyField(ProjectPermission,
#                                                  blank=True)
#     theme = models.CharField(_('App associated theme'),
#                              choices=THEMES,
#                              default=DEFAULT_THEME,
#                              max_length=50,)
# 
#     def __str__(self):
#         return "{0}({1})".format(self.name, self.token)
# 
# Path: wiggum/applications/utils.py
# def generate_api_key():
#     return uuid.uuid4().hex


# Path: wiggum/applications/test_models.py
from django.conf import settings
from django.test import TransactionTestCase
from django.db.utils import IntegrityError
from .models import Application
from users.models import ProjectPermission
from .utils import generate_api_key



class ApplicationModelTest(TransactionTestCase):
    def setUp(self):
        # Initial data
        self.data = [{
            'name': "Batman application",
            'token': generate_api_key(),
            'description': "Bruce Wayne awesome application",
            'active': True, }, {

            'name': "Spiderman application",

            'token': generate_api_key(),