# Path: app/models.py
# class Project(models.Model):
#     name = models.CharField(max_length=100)
#     added = models.DateTimeField(default=datetime.now)
# 
#     def __str__(self):  # __unicode__ on Python 2
#         return self.name
# 
#     class Meta:
#         ordering = ('name',)
# 
# class Assessment(models.Model):
#     name = models.CharField(max_length=100)
#     project = models.ForeignKey(Project, on_delete=models.CASCADE)
#     added = models.DateTimeField(default=datetime.now)
# 
#     def __str__(self):  # __unicode__ on Python 2
#         return self.name
# 
#     class Meta:
#         ordering = ('name',)
# 
# class Sh0t(models.Model):
#     title = models.CharField(max_length=200)
#     body = models.TextField(default="")
#     assessment = models.ForeignKey(Assessment, null=True, on_delete=models.CASCADE)
#     added = models.DateTimeField(default=datetime.now)
#     severity = models.IntegerField(default=5, validators=[MinValueValidator(0), MaxValueValidator(5)])
# 
#     def __str__(self):  # __unicode__ on Python 2
#         return self.title
# 
#     class Meta:
#         ordering = ('severity','title',)
# 
# class Flag(models.Model):
#     title = models.CharField(max_length=100)
#     note = models.TextField(default="")
#     assessment = models.ForeignKey(Assessment, null=True, on_delete=models.CASCADE)
#     done = models.BooleanField(default=False)
#     added = models.DateTimeField(default=datetime.now)
#     order = models.IntegerField(default=1)
# 
#     def __str__(self):  # __unicode__ on Python 2
#         return self.title
# 
#     class Meta:
#         ordering = ('title',)
# 
# class Template(models.Model):
#     name = models.CharField(max_length=100)
#     body = models.TextField(default="")
#     added = models.DateTimeField(default=datetime.now)
# 
#     def __str__(self):  # __unicode__ on Python 2
#         return self.name
# 
#     class Meta:
#         ordering = ('name',)


from django.test import TestCase
from .models import Project, Assessment, Sh0t, Flag, Template
    new_project_name = "Project created by automated testing"
    new_flag_name = "Flag created by automated testing"
    new_sh0t_name = "Sh0t created by automated testing"
    new_assessment_name = "Assessment created by automated testing"
    new_template_name = "Template created by automated testing"
    new_template_body = ""

    def __create_a_project(self):
        new_project = Project.objects.create(name=self.new_project_name)
        return new_project

    def __create_an_assessment(self):
        new_project = self.__create_a_project()
        new_assessment = Assessment.objects.create(name=self.new_assessment_name, project=new_project)
        new_assessment.save()
        return new_assessment

    def __create_a_flag(self):
        new_assessment = self.__create_an_assessment()
        new_flag = Flag.objects.create(title=self.new_flag_name, assessment=new_assessment)
        return new_flag

    def __create_a_sh0t(self):
        new_assessment = self.__create_an_assessment()
        new_sh0t = Sh0t.objects.create(title=self.new_sh0t_name, assessment=new_assessment)
        return new_sh0t

    def __create_a_template(self):
        new_template = Template.objects.create(name=self.new_template_name, body=self.new_template_body)
        new_template.save()

# Path: app/models.py
# class Project(models.Model):
#     name = models.CharField(max_length=100)
#     added = models.DateTimeField(default=datetime.now)
# 
#     def __str__(self):  # __unicode__ on Python 2
#         return self.name
# 
#     class Meta:
#         ordering = ('name',)
# 
# class Assessment(models.Model):
#     name = models.CharField(max_length=100)
#     project = models.ForeignKey(Project, on_delete=models.CASCADE)
#     added = models.DateTimeField(default=datetime.now)
# 
#     def __str__(self):  # __unicode__ on Python 2
#         return self.name
# 
#     class Meta:
#         ordering = ('name',)
# 
# class Sh0t(models.Model):
#     title = models.CharField(max_length=200)
#     body = models.TextField(default="")
#     assessment = models.ForeignKey(Assessment, null=True, on_delete=models.CASCADE)
#     added = models.DateTimeField(default=datetime.now)
#     severity = models.IntegerField(default=5, validators=[MinValueValidator(0), MaxValueValidator(5)])
# 
#     def __str__(self):  # __unicode__ on Python 2
#         return self.title
# 
#     class Meta:
#         ordering = ('severity','title',)
# 
# class Flag(models.Model):
#     title = models.CharField(max_length=100)
#     note = models.TextField(default="")
#     assessment = models.ForeignKey(Assessment, null=True, on_delete=models.CASCADE)
#     done = models.BooleanField(default=False)
#     added = models.DateTimeField(default=datetime.now)
#     order = models.IntegerField(default=1)
# 
#     def __str__(self):  # __unicode__ on Python 2
#         return self.title
# 
#     class Meta:
#         ordering = ('title',)
# 
# class Template(models.Model):
#     name = models.CharField(max_length=100)
#     body = models.TextField(default="")
#     added = models.DateTimeField(default=datetime.now)
# 
#     def __str__(self):  # __unicode__ on Python 2
#         return self.name
# 
#     class Meta:
#         ordering = ('name',)


# Path: app/tests.py
from django.test import TestCase
from .models import Project, Assessment, Sh0t, Flag, Template

    new_project_name = "Project created by automated testing"
    new_flag_name = "Flag created by automated testing"
    new_sh0t_name = "Sh0t created by automated testing"
    new_assessment_name = "Assessment created by automated testing"
    new_template_name = "Template created by automated testing"
    new_template_body = ""

    def __create_a_project(self):
        new_project = Project.objects.create(name=self.new_project_name)
        return new_project

    def __create_an_assessment(self):
        new_project = self.__create_a_project()
        new_assessment = Assessment.objects.create(name=self.new_assessment_name, project=new_project)
        new_assessment.save()
        return new_assessment

    def __create_a_flag(self):
        new_assessment = self.__create_an_assessment()
        new_flag = Flag.objects.create(title=self.new_flag_name, assessment=new_assessment)
        return new_flag

    def __create_a_sh0t(self):
        new_assessment = self.__create_an_assessment()
        new_sh0t = Sh0t.objects.create(title=self.new_sh0t_name, assessment=new_assessment)
        return new_sh0t

    def __create_a_template(self):
        new_template = Template.objects.create(name=self.new_template_name, body=self.new_template_body)
        new_template.save()

        return  new_template