Finished heroes unit test.

parent 3a3d17bd
testenv/ env/
__pycache__ __pycache__
*.pyc *.pyc
geckodriver.exe
...@@ -4,34 +4,33 @@ import unittest ...@@ -4,34 +4,33 @@ import unittest
class NewVisitorTest(unittest.TestCase): class NewVisitorTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.browser = webdriver.Firefox() self.browser = webdriver.Firefox()
def tearDown(self): def tearDown(self):
self.browser.quit() self.browser.quit()
def test_can_display_a_heroes_list_and_more_information_per_hero(self): def test_can_display_a_heroes_list_and_more_information_per_hero(self):
# Widget has heard about a new wiki app for the game called The Will of the Wisps. # Widget has heard about a new wiki app for the game called The Will of the Wisps.
# She goes to check out its homepage # She goes to check out its homepage
self.browser.get('http://localhost:8000') self.browser.get('http://localhost:8000/heroes')
# She notices the page title and header mention # She notices the page title and header mention
# 'The Will of the Wisps Wiki' # 'The Will of the Wisps Wiki'
self.assertIn('The Will of the Wisps Wiki', self.browser.title) self.assertIn('The Will of the Wisps Wiki', self.browser.title)
# She sees a list containing three heroes with their corresponding # She sees a list containing three heroes with their corresponding
# names, health points, and damage # names, health points, and damage
self.browser.get('http:://localhost:8000/heroes')
# When she selects one of the heroes, she is sent to another page # When she selects one of the heroes, she is sent to another page
# containing more information about the hero (additional stats, lore, image). # containing more information about the hero (additional stats, lore, image).
self.browser.get('http://localhost:8000/hero/cloud') self.browser.get('http://localhost:8000/hero/cloud')
# She spots the page title and header mentions the name of the hero she selected. # She spots the page title and header mentions the name of the hero she selected.
self.assertIn('Detail - Cloud', self.browser.title) self.assertIn('Detail - Cloud', self.browser.title)
# While she is in a specific hero's page, she sees a button labeled "Back to Heroes List". # 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. # She clicks this and she is redirected back to the wiki's homepage.
self.browser.get('http://localhost:8000') self.browser.get('http://localhost:8000')
self.fail('Finish the test!') self.fail('Finish the test!')
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -3,8 +3,5 @@ from django.test import TestCase ...@@ -3,8 +3,5 @@ from django.test import TestCase
class HomePageTest(TestCase): class HomePageTest(TestCase):
def test_heroes_page_returns_correct_html(self): def test_heroes_page_returns_correct_html(self):
response = self.client.get('/') response = self.client.get('/heroes/')
html = response.content.decode('utf8')
self.assertTemplateUsed(response, 'heroes.html') self.assertTemplateUsed(response, 'heroes.html')
from django.conf.urls import url from django.conf.urls import url
from .views import heroes_page from .views import heroes_page, cloud_page, sunflowey_page, jester_page
urlpatterns = [ urlpatterns = [
url(r'^heroes/$', heroes_page, name='heroes_page'), url(r'^heroes/$', heroes_page, name='heroes_page'),
url(r'^hero/cloud$', cloud_page, name='cloud_page'), url(r'^hero/cloud$', cloud_page, name='cloud_page'),
url(r'^hero/sunflowey$', sunflowey_page, name='sunflowey_page'), url(r'^hero/sunflowey$', sunflowey_page, name='cloud_page'),
url(r'^hero/jester$', jester_page, name='jester_page'), url(r'^hero/jester$', jester_page, name='cloud_page'),
] ]
...@@ -2,3 +2,12 @@ from django.shortcuts import render ...@@ -2,3 +2,12 @@ from django.shortcuts import render
def heroes_page(request): def heroes_page(request):
return render(request, 'heroes.html') return render(request, 'heroes.html')
def cloud_page(request):
pass
def sunflowey_page(request):
pass
def jester_page(request):
pass
from selenium import webdriver
import unittest
class NewVisitorTest(unittest.TestCase):
def setUp(self):
self.browser = webdriver.Firefox()
def tearDown(self):
self.browser.quit()
def test_can_display_a_heroes_list_and_more_information_per_hero(self):
# Widget has heard about a new wiki app for the game called The Will of the Wisps.
# She goes to check out its homepage
browser.get('http://localhost:8000')
# She notices the page title and header mention
# 'The Will of the Wisps Wiki'
self.assertIn('The Will of the Wisps Wiki', self.browser.title)
# She sees a list containing three heroes with their corresponding
# names, health points, and damage
# When she selects one of the heroes, she is sent to another page
# containing more information about the hero (additional stats, lore, image).
# She spots the page title and header mentions the name of the hero she selected.
# 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.
self.fail('Finish the test!')
\ No newline at end of file
...@@ -37,6 +37,7 @@ INSTALLED_APPS = [ ...@@ -37,6 +37,7 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'heroes',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
...@@ -75,8 +76,12 @@ WSGI_APPLICATION = 'willowisp.wsgi.application' ...@@ -75,8 +76,12 @@ WSGI_APPLICATION = 'willowisp.wsgi.application'
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 'NAME': 'willowisp',
'USER': 'postgres',
'PASSWORD': 'tabatsoy11',
'HOST': 'localhost',
'PORT': '5432',
} }
} }
......
"""willowisp URL Configuration from django.conf.urls import include, url
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin from django.contrib import admin
urlpatterns = [ urlpatterns = [
url(r'^admin/', admin.site.urls), url(r'^admin/', admin.site.urls),
url(r'', include('heroes.urls')),
] ]
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