# Path: apps/taxonomy/tests/base.py
# class TaxonomyUnauthorizedTestMixin(UnauthorizedTestMixin):
# 
#     def setUp(self):
#         super(TaxonomyUnauthorizedTestMixin, self).setUp()
#         factories.TaxonRankFactory(id=0)
# 
# class TaxonomyUserTestMixin(UserTestMixin):
# 
#     def setUp(self):
#         super(TaxonomyUserTestMixin, self).setUp()
#         factories.TaxonRankFactory(id=0)
# 
# class TaxonomyAdminTestMixin(AdminTestMixin):
# 
#     def setUp(self):
#         super(TaxonomyAdminTestMixin, self).setUp()
#         factories.TaxonRankFactory(id=0)
# 
# Path: apps/taxonomy/tests/factories.py
# class CommonNameFactory(factory.django.DjangoModelFactory):
#     taxon_node = factory.SubFactory(TaxonNodeFactory)
#     iso_639 = factory.SubFactory(LanguageFactory)
#     common_name = "Common Kingdom"
# 
#     class Meta:
#         model = models.CommonName
# 
# class TaxonNodeFactory(factory.django.DjangoModelFactory):
#     tree = factory.SubFactory(TreeFactory)
#     epithet = 'kingdom'
#     parent_described_in = None
#     valid_name = None
#     taxon_rank = factory.SubFactory(TaxonRankFactory)
#     taxon_name_concept = None
#     epithet_author = 'author'
#     is_fossil = False
# 
#     class Meta:
#         model = models.TaxonNode
# 
# class TreeFactory(factory.django.DjangoModelFactory):
#     name = 'Tree 1'
#     origin_tree = None
#     root_node = None  # factory.SubFactory(TaxonNodeFactory)
# 
#     class Meta:
#         model = models.Tree
# 
# class LanguageFactory(factory.django.DjangoModelFactory):
#     iso_639 = 'est'
#     name = 'estonian'
# 
#     class Meta:
#         model = models.Language
# 
# Path: apps/taxonomy/models.py
# class Language(models.Model):
#     iso_639 = models.CharField(max_length=3, primary_key=True)
#     name = models.CharField(max_length=255)
# 
#     def __unicode__(self):
#         return self.name


from rest_framework.reverse import reverse
from rest_framework.test import APITestCase
from django.core.exceptions import ObjectDoesNotExist
from apps.taxonomy.tests.base import TaxonomyUnauthorizedTestMixin, TaxonomyUserTestMixin, TaxonomyAdminTestMixin
from apps.taxonomy.tests.factories import CommonNameFactory, TaxonNodeFactory, TreeFactory, LanguageFactory
from apps.taxonomy.models import Language



class CommonNameBase(APITestCase):

    def get_obj_url(self):
        obj = CommonNameFactory(taxon_node=TaxonNodeFactory())
        return reverse('commonname-detail', args=[obj.id]), obj

    @staticmethod
    def get_url():
        return reverse('commonname-list')

    def get_raw_data(self):

# Path: apps/taxonomy/tests/base.py
# class TaxonomyUnauthorizedTestMixin(UnauthorizedTestMixin):
# 
#     def setUp(self):
#         super(TaxonomyUnauthorizedTestMixin, self).setUp()
#         factories.TaxonRankFactory(id=0)
# 
# class TaxonomyUserTestMixin(UserTestMixin):
# 
#     def setUp(self):
#         super(TaxonomyUserTestMixin, self).setUp()
#         factories.TaxonRankFactory(id=0)
# 
# class TaxonomyAdminTestMixin(AdminTestMixin):
# 
#     def setUp(self):
#         super(TaxonomyAdminTestMixin, self).setUp()
#         factories.TaxonRankFactory(id=0)
# 
# Path: apps/taxonomy/tests/factories.py
# class CommonNameFactory(factory.django.DjangoModelFactory):
#     taxon_node = factory.SubFactory(TaxonNodeFactory)
#     iso_639 = factory.SubFactory(LanguageFactory)
#     common_name = "Common Kingdom"
# 
#     class Meta:
#         model = models.CommonName
# 
# class TaxonNodeFactory(factory.django.DjangoModelFactory):
#     tree = factory.SubFactory(TreeFactory)
#     epithet = 'kingdom'
#     parent_described_in = None
#     valid_name = None
#     taxon_rank = factory.SubFactory(TaxonRankFactory)
#     taxon_name_concept = None
#     epithet_author = 'author'
#     is_fossil = False
# 
#     class Meta:
#         model = models.TaxonNode
# 
# class TreeFactory(factory.django.DjangoModelFactory):
#     name = 'Tree 1'
#     origin_tree = None
#     root_node = None  # factory.SubFactory(TaxonNodeFactory)
# 
#     class Meta:
#         model = models.Tree
# 
# class LanguageFactory(factory.django.DjangoModelFactory):
#     iso_639 = 'est'
#     name = 'estonian'
# 
#     class Meta:
#         model = models.Language
# 
# Path: apps/taxonomy/models.py
# class Language(models.Model):
#     iso_639 = models.CharField(max_length=3, primary_key=True)
#     name = models.CharField(max_length=255)
# 
#     def __unicode__(self):
#         return self.name


# Path: apps/taxonomy/tests/acceptance_tests/test_commonname_api.py
from rest_framework.reverse import reverse
from rest_framework.test import APITestCase
from django.core.exceptions import ObjectDoesNotExist
from apps.taxonomy.tests.base import TaxonomyUnauthorizedTestMixin, TaxonomyUserTestMixin, TaxonomyAdminTestMixin
from apps.taxonomy.tests.factories import CommonNameFactory, TaxonNodeFactory, TreeFactory, LanguageFactory
from apps.taxonomy.models import Language




class CommonNameBase(APITestCase):

    def get_obj_url(self):
        obj = CommonNameFactory(taxon_node=TaxonNodeFactory())
        return reverse('commonname-detail', args=[obj.id]), obj

    @staticmethod
    def get_url():
        return reverse('commonname-list')

    def get_raw_data(self):

        taxon_node_url = reverse('taxonnode-detail', args=[TaxonNodeFactory(tree=TreeFactory()).id])