Commit c02d7cda authored by Lance Michael O. Co's avatar Lance Michael O. Co 😢

FTs finished, UTs finished

parent b703a2fa
# heroes/test.py
from django.urls import resolve
from django.test import TestCase
from django.http import HttpRequest
from .views import home_page
from .views import HomeView, HeroesView, CloudView, SunfloweyView, JesterView
class HomePageTest(TestCase):
def test_root_url_resolves_to_home_page_view(self):
found = resolve('/')
self.assertEqual(found.func, home_page)
def test_home_page_returns_correct_html(self):
request = HttpRequest()
response = home_page(request)
html = response.content.decode('utf8')
self.assertTrue(html.startswith('<html>'))
self.assertIn('<title>To-Do lists</title>', html)
self.assertTrue(html.endswith('</html>'))
def test_uses_home_template(self):
response = self.client.get('/')
self.assertTemplateUsed(response, 'home.html')
class HeroesPageTest(TestCase):
def test_uses_home_template(self):
response = self.client.get('/heroes')
self.assertTemplateUsed(response, 'heroes.html')
class CloudPageTest(TestCase):
def test_uses_home_template(self):
response = self.client.get('/heroes/cloud')
self.assertTemplateUsed(response, 'detail_cloud.html')
class SunfloweyPageTest(TestCase):
def test_uses_home_template(self):
response = self.client.get('/heroes/sunflowey')
self.assertTemplateUsed(response, 'detail_sunflowey.html')
class JesterPageTest(TestCase):
def test_uses_home_template(self):
response = self.client.get('/heroes/jester')
self.assertTemplateUsed(response, 'detail_jester.html')
......@@ -20,21 +20,63 @@ class NewVisitorTest(unittest.TestCase):
# She sees a list containing three heroes with their corresponding
# names, health points, and damage
self.browser.get('http://localhost:8000/heroes')
input = self.browser.find_element_by_id('id_new_item')
self.assertEqual(input.get_attribute('placeholder'), 'Enter a to-do item')
element = self.browser.find_element_by_id('cloud-name')
self.assertEqual(element.get_attribute('placeholder'), 'Name: Cloud')
element = self.browser.find_element_by_id('cloud-hp')
self.assertEqual(element.get_attribute('placeholder'), 'HP: 600')
element = self.browser.find_element_by_id('cloud-dmg')
self.assertEqual(element.get_attribute('placeholder'), 'Dmg: 57')
element = self.browser.find_element_by_id('jester-name')
self.assertEqual(element.get_attribute('placeholder'), 'Name: Sunflowey')
element = self.browser.find_element_by_id('sunflowey-hp')
self.assertEqual(element.get_attribute('placeholder'), 'HP: 650')
element = self.browser.find_element_by_id('sunflowey-dmg')
self.assertEqual(element.get_attribute('placeholder'), 'Dmg: 43')
self.assertEqual(element.get_attribute('placeholder'), 'Name: Jester')
element = self.browser.find_element_by_id('jester-hp')
self.assertEqual(element.get_attribute('placeholder'), 'HP: 660')
element = self.browser.find_element_by_id('jester-dmg')
self.assertEqual(element.get_attribute('placeholder'), 'Dmg: 64')
element = self.browser.find_element_by_id('sunflowey-name')
# When she selects one of the heroes, she is sent to another page
# containing more information about the hero (additional stats, lore, image).
self.browser.get('http://localhost:8000/heroes/cloud')
element = self.browser.find_element_by_id('cloud-name')
self.assertEqual(element.get_attribute('placeholder'), 'Detail - Cloud')
element = self.browser.find_element_by_id('cloud-details')
self.assertEqual(element.get_attribute('placeholder'), '<dt>Health Points</dt><dd>600</dd><dt>Base Attack Damage</dt><dd>57</dd><dt>Skills</dt><dd>Nimbus, Rain Cloud, Thunderbolt</dd><dt>Lore</dt><dd>I am a cloud. When I pee you call it \'rain\'.</dd>')
self.browser.get('http://localhost:8000/heroes/jester')
element = self.browser.find_element_by_id('jester-name')
self.assertEqual(element.get_attribute('placeholder'), 'Detail - Jester')
element = self.browser.find_element_by_id('jester-details')
self.assertEqual(element.get_attribute('placeholder'), '<dt>Health Points</dt><dd>660</dd><dt>Base Attack Damage</dt><dd>64</dd><dt>Skills</dt><dd>Laugh, Dance, Smile</dd><dt>Lore</dt><dd>I do it for the LOLs.</dd>')
self.browser.get('http://localhost:8000/heroes/sunflowey')
element = self.browser.find_element_by_id('sunflowey-name')
self.assertEqual(element.get_attribute('placeholder'), 'Detail - Sunflowey')
element = self.browser.find_element_by_id('sunflowey-details')
self.assertEqual(element.get_attribute('placeholder'), '<dt>Health Points</dt><dd>650</dd><dt>Base Attack Damage</dt><dd>43</dd><dt>Skills</dt><dd>Power Pellet, Sunshine, Pollen Punch</dd><dt>Lore</dt><dd>I am Sunflowey. Sometimes a sun, sometimes a flower.</dd>')
#test for the urls and others
# She spots the page title and header mentions the name of the hero she selected.
self.assertIn(hero, self.browser.title)
self.browser.get('http://localhost:8000/heroes/cloud')
self.assertIn('Details - Cloud')
self.browser.get('http://localhost:8000/heroes/sunflowey')
self.assertIn('Details - Sunflowey')
self.browser.get('http://localhost:8000/heroes/jester')
self.assertIn('Details - Jester')
# While she is in a specific hero's page, she sees a button labeled "Back to Heroes List".
# She clicks this and she is redirected back to the wiki's homepage.
#test for redirect thingo
#TODO figure out how to make buttons huhuhu
self.fail('Finish the test!')
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment