from django.contrib.contenttypes.models import ContentType

from fluent_contents.models import ContentItem
from fluent_contents.tests.utils import AppTestCase


class ModelTests(AppTestCase):
    """
    Testing the data model.
    """

    def test_stale_model_str(self):
        """
        No matter what, the ContentItem.__str__() should work.
        This would break the admin delete screen otherwise.
        """
        c = ContentType()
        a = ContentItem(polymorphic_ctype=c)
        self.assertEqual(str(a), "'(type deleted) 0' in 'None None'")

from django.contrib.contenttypes.models import ContentType

from fluent_contents.models import ContentItem
from fluent_contents.tests.utils import AppTestCase


class ModelTests(AppTestCase):
    """
    Testing the data model.
    """

    def test_stale_model_str(self):
        """
        No matter what, the ContentItem.__str__() should work.
        This would break the admin delete screen otherwise.
        """
        c = ContentType()
        c.save()
        a = ContentItem(polymorphic_ctype=c)
        self.assertEqual(str(a), "'(type deleted) 0' in 'None None'")

Fix Django 1.8+ tests for stale content type
Fix Django 1.8+ tests for stale content type

  from django.contrib.contenttypes.models import ContentType
  
  from fluent_contents.models import ContentItem
  from fluent_contents.tests.utils import AppTestCase
  
  
  class ModelTests(AppTestCase):
      """
      Testing the data model.
      """
  
      def test_stale_model_str(self):
          """
          No matter what, the ContentItem.__str__() should work.
          This would break the admin delete screen otherwise.
          """
          c = ContentType()
+         c.save()
          a = ContentItem(polymorphic_ctype=c)
          self.assertEqual(str(a), "'(type deleted) 0' in 'None None'")
  
Fix Django 1.8+ tests for stale content type
## Code Before:
from django.contrib.contenttypes.models import ContentType

from fluent_contents.models import ContentItem
from fluent_contents.tests.utils import AppTestCase


class ModelTests(AppTestCase):
    """
    Testing the data model.
    """

    def test_stale_model_str(self):
        """
        No matter what, the ContentItem.__str__() should work.
        This would break the admin delete screen otherwise.
        """
        c = ContentType()
        a = ContentItem(polymorphic_ctype=c)
        self.assertEqual(str(a), "'(type deleted) 0' in 'None None'")

## Instruction:
Fix Django 1.8+ tests for stale content type
## Code After:
from django.contrib.contenttypes.models import ContentType

from fluent_contents.models import ContentItem
from fluent_contents.tests.utils import AppTestCase


class ModelTests(AppTestCase):
    """
    Testing the data model.
    """

    def test_stale_model_str(self):
        """
        No matter what, the ContentItem.__str__() should work.
        This would break the admin delete screen otherwise.
        """
        c = ContentType()
        c.save()
        a = ContentItem(polymorphic_ctype=c)
        self.assertEqual(str(a), "'(type deleted) 0' in 'None None'")
