title: Basic django-pytest tests
body: <p>Even just learning the django and testwriting, so I need a bit of confirmation. I would like to know that the following tests are "correct" spelling of it.</p>
  
  <p>test_view.py</p>
  
  <pre><code>@pytest.mark.django_db
  def test_create_form(client):
      form_data = {'title': 'Test Title', 'tags': 'HTML', 'content': 'New Content for lambs'}
      response = client.post(reverse("public:create"), form_data, follow=True)
      assert b'Test Title' in response.content
  
  @pytest.mark.django_db
  def test_context_create(client):
     form_data = {'title': 'Test Title', 'tags': 'HTML', 'content': 'New Content for lambs'}
     response = client.post(reverse("public:create"), form_data)
     assert response.context['form'].cleaned_data['title'] == 'Test Title'
  
  @pytest.mark.django_db
  def test_TITLE_is_blank(client):
      form_data = {'title': '', 'tags': 'HTML', 'content': 'New Content for lambs'}
      response = client.post(reverse("public:create"), form_data)
      assert response.context['form'].cleaned_data['title'] == ''
  
  @pytest.mark.django_db
  def test_CONTENT_is_blank(client):
      form_data = {'title': 'Test Title', 'tags': 'HTML', 'content': ''}
      response = client.post(reverse("public:create"), form_data)
      assert response.context['form'].cleaned_data['content'] == ''
  
  @pytest.mark.django_db
  def test_CONTENT_and_TITLE_is_blank(client):
      form_data = {'title': '', 'tags': 'HTML', 'content': ''}
      response = client.post(reverse("public:create"), form_data)
      assert (not response.context['form'].is_valid())
  </code></pre>
  
  <p>forms.py   </p>
  
  <pre><code>class PostForm(ModelForm):
  
      def __init__(self, *args, **kwargs):
          super(PostForm, self).__init__(*args,**kwargs)
  
          self.fields['title'].required = False
          self.fields['content'].required = False
  
      class Meta:
          model = Post
          fields = ['title', 'tags', 'content']
  
      def clean(self):
          form_data = self.cleaned_data
  
          if (form_data['title'] is not "") or (form_data['content'] is not ""):
              return form_data
          else:
             self._errors["title"] = ["Two field is empty"]
  
  
      def save(self, *args, **kwargs):
          instance = super(PostForm, self).save(commit=False)
          instance.slug = slugify(instance.title)
          instance.save()
  
          return instance
  </code></pre>
  
  <p>This is the model</p>
  
  <pre><code>class Post(models.Model):
      title = models.CharField(max_length=200)
      tags = models.ManyToManyField(Tags)
      slug = models.SlugField(max_length=200, blank=True)
      creation_date = models.DateTimeField(auto_now_add=True)
      modify_date = models.DateTimeField(auto_now=True)
      content = models.TextField()
  </code></pre>
  
  <p>Thank you for your help and advice.</p>