# Path: configuration/models.py
# class MethodologyMaster(models.Model):
#     name = models.CharField(max_length=100)
#     description = models.TextField(default="")
#     order = models.IntegerField(default=0)
#     created_by = models.ForeignKey(User, related_name="methodology_created_by", null=True, on_delete=models.CASCADE)
#     created = models.DateTimeField(default=datetime.now)
#     updated_by = models.ForeignKey(User, related_name="methodology_updated_by", null=True, on_delete=models.CASCADE)
#     updated = models.DateTimeField(default=datetime.now)
# 
#     def __str__(self):  # __unicode__ on Python 2
#         return self.name
# 
#     def save(self, *args, **kwargs):
#         if not self.id:
#             self.created = timezone.now()
#         self.updated = timezone.now()
#         return super(MethodologyMaster, self).save(*args, **kwargs)
# 
#     class Meta:
#         ordering = ('name',)
# 
# class ModuleMaster(models.Model):
#     name = models.CharField(max_length=100)
#     description = models.TextField(default="")
#     order = models.IntegerField(default=0)
#     methodology = models.ForeignKey(MethodologyMaster, on_delete=models.CASCADE, null=True, default=None)
#     created_by = models.ForeignKey(User, related_name="module_created_by", null=True, on_delete=models.CASCADE)
#     created = models.DateTimeField(default=datetime.now)
#     updated_by = models.ForeignKey(User, related_name="module_updated_by", null=True, on_delete=models.CASCADE)
#     updated = models.DateTimeField(default=datetime.now)
# 
#     def __str__(self):  # __unicode__ on Python 2
#         return self.name
# 
#     def save(self, *args, **kwargs):
#         if not self.id:
#             self.created = timezone.now()
#         self.updated = timezone.now()
#         return super(ModuleMaster, self).save(*args, **kwargs)
# 
#     class Meta:
#         ordering = ('name',)
# 
# class CaseMaster(models.Model):
#     name = models.CharField(max_length=100)
#     module = models.ForeignKey(ModuleMaster, on_delete=models.CASCADE)
#     description = models.TextField(default="")
#     order = models.IntegerField(default=0)
#     created_by = models.ForeignKey(User, related_name="case_module_created_by", null=True, on_delete=models.CASCADE)
#     created = models.DateTimeField(default=datetime.now)
#     updated_by = models.ForeignKey(User, related_name="case_module_updated_by", null=True, on_delete=models.CASCADE)
#     updated = models.DateTimeField(default=datetime.now)
# 
#     def __str__(self):  # __unicode__ on Python 2
#         return self.name
# 
#     def save(self, *args, **kwargs):
#         if not self.id:
#             self.created = timezone.now()
#         self.updated = timezone.now()
#         return super(CaseMaster, self).save(*args, **kwargs)
# 
#     class Meta:
#         ordering = ('name',)


from django.test import TestCase
from .models import MethodologyMaster, ModuleMaster, CaseMaster
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

class ModelTests(TestCase):
    new_methodology_name = "Methodology created by automated testing"
    new_module_name = "Module created by automated testing"
    new_case_name = "Case created by automated testing"

    def __create_a_methodology(self):
        new_methodology = MethodologyMaster.objects.create(name=self.new_methodology_name)
        return new_methodology

    def __create_a_module(self):
        new_methodology = self.__create_a_methodology()
        new_module = ModuleMaster.objects.create(name=self.new_module_name, methodology=new_methodology)
        new_module.save()
        return new_module

    def __create_a_case(self):
        new_module = self.__create_a_module()
        new_case = CaseMaster.objects.create(name=self.new_case_name, module=new_module)
        return new_case

    def test_can_create_methodology(self):
        new_methodology = self.__create_a_methodology()
        self.assertEqual(new_methodology.name, self.new_methodology_name)

    def test_can_create_module(self):

# Path: configuration/models.py
# class MethodologyMaster(models.Model):
#     name = models.CharField(max_length=100)
#     description = models.TextField(default="")
#     order = models.IntegerField(default=0)
#     created_by = models.ForeignKey(User, related_name="methodology_created_by", null=True, on_delete=models.CASCADE)
#     created = models.DateTimeField(default=datetime.now)
#     updated_by = models.ForeignKey(User, related_name="methodology_updated_by", null=True, on_delete=models.CASCADE)
#     updated = models.DateTimeField(default=datetime.now)
# 
#     def __str__(self):  # __unicode__ on Python 2
#         return self.name
# 
#     def save(self, *args, **kwargs):
#         if not self.id:
#             self.created = timezone.now()
#         self.updated = timezone.now()
#         return super(MethodologyMaster, self).save(*args, **kwargs)
# 
#     class Meta:
#         ordering = ('name',)
# 
# class ModuleMaster(models.Model):
#     name = models.CharField(max_length=100)
#     description = models.TextField(default="")
#     order = models.IntegerField(default=0)
#     methodology = models.ForeignKey(MethodologyMaster, on_delete=models.CASCADE, null=True, default=None)
#     created_by = models.ForeignKey(User, related_name="module_created_by", null=True, on_delete=models.CASCADE)
#     created = models.DateTimeField(default=datetime.now)
#     updated_by = models.ForeignKey(User, related_name="module_updated_by", null=True, on_delete=models.CASCADE)
#     updated = models.DateTimeField(default=datetime.now)
# 
#     def __str__(self):  # __unicode__ on Python 2
#         return self.name
# 
#     def save(self, *args, **kwargs):
#         if not self.id:
#             self.created = timezone.now()
#         self.updated = timezone.now()
#         return super(ModuleMaster, self).save(*args, **kwargs)
# 
#     class Meta:
#         ordering = ('name',)
# 
# class CaseMaster(models.Model):
#     name = models.CharField(max_length=100)
#     module = models.ForeignKey(ModuleMaster, on_delete=models.CASCADE)
#     description = models.TextField(default="")
#     order = models.IntegerField(default=0)
#     created_by = models.ForeignKey(User, related_name="case_module_created_by", null=True, on_delete=models.CASCADE)
#     created = models.DateTimeField(default=datetime.now)
#     updated_by = models.ForeignKey(User, related_name="case_module_updated_by", null=True, on_delete=models.CASCADE)
#     updated = models.DateTimeField(default=datetime.now)
# 
#     def __str__(self):  # __unicode__ on Python 2
#         return self.name
# 
#     def save(self, *args, **kwargs):
#         if not self.id:
#             self.created = timezone.now()
#         self.updated = timezone.now()
#         return super(CaseMaster, self).save(*args, **kwargs)
# 
#     class Meta:
#         ordering = ('name',)


# Path: configuration/tests.py
from django.test import TestCase
from .models import MethodologyMaster, ModuleMaster, CaseMaster

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

class ModelTests(TestCase):
    new_methodology_name = "Methodology created by automated testing"
    new_module_name = "Module created by automated testing"
    new_case_name = "Case created by automated testing"

    def __create_a_methodology(self):
        new_methodology = MethodologyMaster.objects.create(name=self.new_methodology_name)
        return new_methodology

    def __create_a_module(self):
        new_methodology = self.__create_a_methodology()
        new_module = ModuleMaster.objects.create(name=self.new_module_name, methodology=new_methodology)
        new_module.save()
        return new_module

    def __create_a_case(self):
        new_module = self.__create_a_module()
        new_case = CaseMaster.objects.create(name=self.new_case_name, module=new_module)
        return new_case

    def test_can_create_methodology(self):
        new_methodology = self.__create_a_methodology()
        self.assertEqual(new_methodology.name, self.new_methodology_name)

    def test_can_create_module(self):

        new_module = self.__create_a_module()