from django.test import TestCase

from ..registry import LinguistRegistry as Registry
from ..models import Translation

from . import settings
from .translations import FooModel, FooTranslation


class BaseTestCase(TestCase):
    """
    Base test class mixin.
    """

    @property
    def languages(self):
        return [language[0] for language in settings.LANGUAGES]

    @property
    def translation_en(self):
        obj, created = Translation.objects.get_or_create(
            identifier='foo',
            object_id=self.instance.pk,
            language='en',
            field_name='title',
            field_value='Hello')
        return obj

    @property
    def translation_fr(self):
        obj, created = Translation.objects.get_or_create(
            identifier='foo',
            object_id=self.instance.pk,
            language='fr',
            field_name='title',
            field_value='bonjour')
        return obj

    def create_registry(self):
        self.registry = Registry()
        self.registry.register(FooTranslation)
        self.instance = FooModel()

from django.test import TestCase

from ..models import Translation

from . import settings
from .translations import FooModel


class BaseTestCase(TestCase):
    """
    Base test class mixin.
    """

    @property
    def languages(self):
        return [language[0] for language in settings.LANGUAGES]

    @property
    def translation_en(self):
        obj, created = Translation.objects.get_or_create(
            identifier='foo',
            object_id=self.instance.pk,
            language='en',
            field_name='title',
            field_value='Hello')
        return obj

    @property
    def translation_fr(self):
        obj, created = Translation.objects.get_or_create(
            identifier='foo',
            object_id=self.instance.pk,
            language='fr',
            field_name='title',
            field_value='bonjour')
        return obj

    def setup_models(self):
        self.instance = FooModel()

Update BaseTest class (removing registry).
Update BaseTest class (removing registry).

  from django.test import TestCase
  
- from ..registry import LinguistRegistry as Registry
  from ..models import Translation
  
  from . import settings
- from .translations import FooModel, FooTranslation
+ from .translations import FooModel
  
  
  class BaseTestCase(TestCase):
      """
      Base test class mixin.
      """
  
      @property
      def languages(self):
          return [language[0] for language in settings.LANGUAGES]
  
      @property
      def translation_en(self):
          obj, created = Translation.objects.get_or_create(
              identifier='foo',
              object_id=self.instance.pk,
              language='en',
              field_name='title',
              field_value='Hello')
          return obj
  
      @property
      def translation_fr(self):
          obj, created = Translation.objects.get_or_create(
              identifier='foo',
              object_id=self.instance.pk,
              language='fr',
              field_name='title',
              field_value='bonjour')
          return obj
  
+     def setup_models(self):
-     def create_registry(self):
-         self.registry = Registry()
-         self.registry.register(FooTranslation)
          self.instance = FooModel()
  
Update BaseTest class (removing registry).
## Code Before:
from django.test import TestCase

from ..registry import LinguistRegistry as Registry
from ..models import Translation

from . import settings
from .translations import FooModel, FooTranslation


class BaseTestCase(TestCase):
    """
    Base test class mixin.
    """

    @property
    def languages(self):
        return [language[0] for language in settings.LANGUAGES]

    @property
    def translation_en(self):
        obj, created = Translation.objects.get_or_create(
            identifier='foo',
            object_id=self.instance.pk,
            language='en',
            field_name='title',
            field_value='Hello')
        return obj

    @property
    def translation_fr(self):
        obj, created = Translation.objects.get_or_create(
            identifier='foo',
            object_id=self.instance.pk,
            language='fr',
            field_name='title',
            field_value='bonjour')
        return obj

    def create_registry(self):
        self.registry = Registry()
        self.registry.register(FooTranslation)
        self.instance = FooModel()

## Instruction:
Update BaseTest class (removing registry).
## Code After:
from django.test import TestCase

from ..models import Translation

from . import settings
from .translations import FooModel


class BaseTestCase(TestCase):
    """
    Base test class mixin.
    """

    @property
    def languages(self):
        return [language[0] for language in settings.LANGUAGES]

    @property
    def translation_en(self):
        obj, created = Translation.objects.get_or_create(
            identifier='foo',
            object_id=self.instance.pk,
            language='en',
            field_name='title',
            field_value='Hello')
        return obj

    @property
    def translation_fr(self):
        obj, created = Translation.objects.get_or_create(
            identifier='foo',
            object_id=self.instance.pk,
            language='fr',
            field_name='title',
            field_value='bonjour')
        return obj

    def setup_models(self):
        self.instance = FooModel()
