From 78cccfce51bc79cd5f93738adc68245a68167ec7 Mon Sep 17 00:00:00 2001 From: jaeyoungleeee Date: Thu, 20 Oct 2022 18:55:34 +0900 Subject: [PATCH 1/2] add test --- toh/hero/tests.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/toh/hero/tests.py b/toh/hero/tests.py index 7ce503c..4b6bc90 100644 --- a/toh/hero/tests.py +++ b/toh/hero/tests.py @@ -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()) \ No newline at end of file From 44a8f7f7f4e9ce84c49ed6acb1666277c4346862 Mon Sep 17 00:00:00 2001 From: jerry96 <35989106+jaeyoungleeee@users.noreply.github.com> Date: Thu, 20 Oct 2022 18:57:12 +0900 Subject: [PATCH 2/2] Update toh/hero/tests.py --- toh/hero/tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/toh/hero/tests.py b/toh/hero/tests.py index 4b6bc90..ea0de31 100644 --- a/toh/hero/tests.py +++ b/toh/hero/tests.py @@ -19,4 +19,5 @@ def test_response_request(self) -> None: second_response = client.get('/hero/') self.assertIn('1', first_response.content.decode()) - self.assertIn('2', second_response.content.decode()) \ No newline at end of file + self.assertIn('2', second_response.content.decode()) + \ No newline at end of file