from django.test import TestCase

from opps.articles.models import Post


class PostModelTest(TestCase):

    fixtures = ['tests/initial_data.json']

    def test_basic_post_exist(self):
        post = Post.objects.all()

        self.assertTrue(post)
        self.assertEqual(len(post), 1)
        self.assertEqual(post[0].slug, u'test-post-application')
        self.assertEqual(post[0].title, u'test post application')
        self.assertTrue(post[0].short_url)

from django.test import TestCase

from opps.articles.models import Post


class PostModelTest(TestCase):

    fixtures = ['tests/initial_data.json']

    def test_basic_post_exist(self):
        post = Post.objects.all()

        self.assertTrue(post)
        self.assertEqual(len(post), 1)
        self.assertEqual(post[0].slug, u'test-post-application')
        self.assertEqual(post[0].title, u'test post application')
        self.assertTrue(post[0].short_url)

    def test_child_class(self):
        post = Post.objects.get(id=1)

        self.assertTrue(post.child_class)
        self.assertEqual(post.child_class, 'Post')

Add test articles (post), check child_class
Add test articles (post), check child_class

  from django.test import TestCase
  
  from opps.articles.models import Post
  
  
  class PostModelTest(TestCase):
  
      fixtures = ['tests/initial_data.json']
  
      def test_basic_post_exist(self):
          post = Post.objects.all()
  
          self.assertTrue(post)
          self.assertEqual(len(post), 1)
          self.assertEqual(post[0].slug, u'test-post-application')
          self.assertEqual(post[0].title, u'test post application')
          self.assertTrue(post[0].short_url)
  
+     def test_child_class(self):
+         post = Post.objects.get(id=1)
+ 
+         self.assertTrue(post.child_class)
+         self.assertEqual(post.child_class, 'Post')
+ 
Add test articles (post), check child_class
## Code Before:
from django.test import TestCase

from opps.articles.models import Post


class PostModelTest(TestCase):

    fixtures = ['tests/initial_data.json']

    def test_basic_post_exist(self):
        post = Post.objects.all()

        self.assertTrue(post)
        self.assertEqual(len(post), 1)
        self.assertEqual(post[0].slug, u'test-post-application')
        self.assertEqual(post[0].title, u'test post application')
        self.assertTrue(post[0].short_url)

## Instruction:
Add test articles (post), check child_class
## Code After:
from django.test import TestCase

from opps.articles.models import Post


class PostModelTest(TestCase):

    fixtures = ['tests/initial_data.json']

    def test_basic_post_exist(self):
        post = Post.objects.all()

        self.assertTrue(post)
        self.assertEqual(len(post), 1)
        self.assertEqual(post[0].slug, u'test-post-application')
        self.assertEqual(post[0].title, u'test post application')
        self.assertTrue(post[0].short_url)

    def test_child_class(self):
        post = Post.objects.get(id=1)

        self.assertTrue(post.child_class)
        self.assertEqual(post.child_class, 'Post')
