Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test #55

Open
wants to merge 2 commits into
base: practice/start
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions toh/hero/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
from django.test import TestCase
class HeroTestCase(TestCase):
def setUp(self) -> None:
Hero.objects.create(name='Superman')
Hero.objects.create(name='Batman')
Hero.objects.create(name='Ironman')

# Create your tests here.
def test_hero_count(self):
self.assertEqual(Hero.objects.all().count(), 3)

def test_hero_id(self) -> None:
client = Client()
response = client.get('/hero/1/')

self.assertEqual(response.status_code, 200)
self.assertIn('1', response.content.decode())
def test_response_request(self) -> None:
client = Client()
first_response = client.get('/hero/')
second_response = client.get('/hero/')

self.assertIn('1', first_response.content.decode())
self.assertIn('2', second_response.content.decode())
given131 marked this conversation as resolved.
Show resolved Hide resolved