Skip to content

Instantly share code, notes, and snippets.

@nakimera
Created September 18, 2018 12:21
Show Gist options
  • Save nakimera/9a2221bf6c4a6b4308373a40f76d9f8d to your computer and use it in GitHub Desktop.
Save nakimera/9a2221bf6c4a6b4308373a40f76d9f8d to your computer and use it in GitHub Desktop.
This code tests creation of an article on Author's heaven
from django.test import Client,TestCase
from .models import Article
class ArticleModelTest(TestCase):
self.client = Client()
self.article = Article(
title = "My first django test",
description = "Ever wonder how?",
body = "You have to believe",
tagline : ["dragons", "angularJs"]
)
def test_create_article(self):
"""This method tests creation of an article"""
response = self.client.post("/api/articles", self.article)
return self.assertEqual(response.status_code, 201)
@malep2007
Copy link

@nakimera
Copy link
Author

@malep2007 Yes, I could check for the response message for successful creation of the article

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment