from django.test import TestCase
from django.urls import reverse
from .models import Post


# Create your tests here.
class PostModelTest(TestCase):

    def test_render_markdown(self):
        p = Post(content='aa')
        self.assertEqual(p.html_content, '<p>aa</p>\n')


class PostViewTest(TestCase):

    def test_post_view(self):
        p = Post(
            slug='first-blog',
            title='First blog',
            content='I am hhb',
        )
        p.save()
        url = reverse('blog:post', args=(p.slug,))
        resp = self.client.get(url)
        self.assertContains(resp, 'I am hhb')

from django.test import TestCase
from django.urls import reverse
from .models import Post


# Create your tests here.
class PostModelTest(TestCase):

    def test_render_markdown(self):
        p = Post(content='aa')
        self.assertEqual(p.html_content, '<p>aa</p>\n')


class PostViewTest(TestCase):

    def test_post_view(self):
        p = Post(
            slug='first-blog',
            title='First blog',
            content='I am hhb',
        )
        p.save()
        url = reverse('blog:post', args=(p.slug,))
        resp = self.client.get(url)
        self.assertContains(resp, 'I am hhb, i will fail')

Test fail not to deploy
Test fail not to deploy

  from django.test import TestCase
  from django.urls import reverse
  from .models import Post
  
  
  # Create your tests here.
  class PostModelTest(TestCase):
  
      def test_render_markdown(self):
          p = Post(content='aa')
          self.assertEqual(p.html_content, '<p>aa</p>\n')
  
  
  class PostViewTest(TestCase):
  
      def test_post_view(self):
          p = Post(
              slug='first-blog',
              title='First blog',
              content='I am hhb',
          )
          p.save()
          url = reverse('blog:post', args=(p.slug,))
          resp = self.client.get(url)
-         self.assertContains(resp, 'I am hhb')
+         self.assertContains(resp, 'I am hhb, i will fail')
  
Test fail not to deploy
## Code Before:
from django.test import TestCase
from django.urls import reverse
from .models import Post


# Create your tests here.
class PostModelTest(TestCase):

    def test_render_markdown(self):
        p = Post(content='aa')
        self.assertEqual(p.html_content, '<p>aa</p>\n')


class PostViewTest(TestCase):

    def test_post_view(self):
        p = Post(
            slug='first-blog',
            title='First blog',
            content='I am hhb',
        )
        p.save()
        url = reverse('blog:post', args=(p.slug,))
        resp = self.client.get(url)
        self.assertContains(resp, 'I am hhb')

## Instruction:
Test fail not to deploy
## Code After:
from django.test import TestCase
from django.urls import reverse
from .models import Post


# Create your tests here.
class PostModelTest(TestCase):

    def test_render_markdown(self):
        p = Post(content='aa')
        self.assertEqual(p.html_content, '<p>aa</p>\n')


class PostViewTest(TestCase):

    def test_post_view(self):
        p = Post(
            slug='first-blog',
            title='First blog',
            content='I am hhb',
        )
        p.save()
        url = reverse('blog:post', args=(p.slug,))
        resp = self.client.get(url)
        self.assertContains(resp, 'I am hhb, i will fail')
