Commit 719f35b2 authored by abbeeeeyyyyy's avatar abbeeeeyyyyy

Last files to be updated

parents 3d71b738 7cfdac4f
Pipeline #950 failed with stages
This diff is collapsed.
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class HeroesConfig(AppConfig):
name = 'heroes'
from django.db import models
# Create your models here.
{% load static %}
<!DOCTYPE html>
<html>
......@@ -6,7 +8,7 @@
</head>
<body>
<img src="./cloud.png" style="width: 10vw;" />
<img src="{% static "heroes/images/cloud.png" %}" style="width: 10vw;" />
<h1>Detail - Cloud</h1>
<dl>
<dt>Health Points</dt>
......@@ -18,7 +20,7 @@
<dt>Lore</dt>
<dd>I am a cloud. When I pee you call it 'rain'.</dd>
</dl>
<button class='info' onclick="window.location.href = 'heroes.html';">Back to Heroes List</button>
<button> <a href="{% url "heroes" %}"> Back to Heroes List </a> </button>
</body>
</html>
\ No newline at end of file
{% load static %}
<!DOCTYPE html>
<html>
......@@ -6,7 +8,7 @@
</head>
<body>
<img src="./jester.png" style="width: 10vw;" />
<img src="{% static "heroes/images/jester.png" %}" style="width: 10vw;" />
<h1>Detail - Jester</h1>
<dl>
<dt>Health Points</dt>
......@@ -18,7 +20,7 @@
<dt>Lore</dt>
<dd>I do it for the LOLs.</dd>
</dl>
<button class='info' onclick="window.location.href = 'heroes.html';">Back to Heroes List</button>
<button> <a href="{% url "heroes" %}"> Back to Heroes List </a></button>
</body>
</html>
\ No newline at end of file
{% load static %}
<!DOCTYPE html>
<html>
......@@ -6,7 +8,7 @@
</head>
<body>
<img src="./sunflowey.png" style="width: 10vw;" />
<img src="{% static "heroes/images/sunflowey.png" %}" style="width: 10vw;" />
<h1>Detail - Sunflowey</h1>
<dl>
<dt>Health Points</dt>
......@@ -18,7 +20,7 @@
<dt>Lore</dt>
<dd>I am Sunflowey. Sometimes a sun, sometimes a flower.</dd>
</dl>
<button class='info' onclick="window.location.href = 'heroes.html';">Back to Heroes List</button>
<button> <a href="{% url "heroes" %}">Back to Heroes List </a> </button>
</body>
</html>
\ No newline at end of file
{% load static %}
<html>
<head>
<title> The Will of the Wisps Wiki </title>
</head>
<body>
<h1> Will-O-Wisp Heroes </h1>
<h1 id="jester"> <a href="{% url "jester" %}" > Jester </a> </h1>
<dl>
<dt>Health Points</dt>
<dd id="hp-jester">660</dd>
<dt>Base Attack Damage</dt>
<dd id="d-jester">64</dd>
</dl>
<h1 id="cloud"> <a href="{% url "cloud" %}"> Cloud </a> </h1>
<dl>
<dt>Health Points</dt>
<dd id="hp-cloud">600</dd>
<dt>Base Attack Damage</dt>
<dd id="d-cloud">57</dd>
</dl>
<h1 id="sunflowey"><a href="{% url "sunflowey" %}"> Sunflowey </a> </h1>
<dl>
<dt>Health Points</dt>
<dd id="hp-sunflowey">650</dd>
<dt>Base Attack Damage</dt>
<dd id="d-sunflowey">43</dd>
</dl>
</body>
</html>
\ No newline at end of file
from django.test import TestCase
from django.urls import resolve
from django.http import HttpRequest
from .views import HeroesView
from .views import JesterView
from .views import CloudView
from .views import SunfloweyView
from django.template.loader import render_to_string
# Create your tests here.
class HeroesSiteTest(TestCase):
def test_home_page_returns_correct_html(self):
response = self.client.get('/heroes/')
self.assertTemplateUsed(response, 'heroes.html')
def test_jester_page_returns_correct_html(self):
response = self.client.get('/hero/jester/')
self.assertTemplateUsed(response,'detail_jester.html')
def test_cloud_page_returns_correct_html(self):
response = self.client.get('/hero/cloud/')
self.assertTemplateUsed(response, 'detail_cloud.html')
def test_sunflowey_page_returns_correct_html(self):
response = self.client.get('/hero/sunflowey/')
self.assertTemplateUsed(response, 'detail_sunflowey.html')
from django.urls import path
from django.contrib import admin
from .views import HeroesView
from .views import JesterView
from .views import SunfloweyView
from .views import CloudView
urlpatterns = [
path('', HeroesView.as_view(), name='heroes'),
path('heroes/', HeroesView.as_view(), name='heroes'),
path('hero/jester/', JesterView.as_view(), name='jester'),
path('hero/sunflowey/', SunfloweyView.as_view(), name='sunflowey'),
path('hero/cloud/', CloudView.as_view(), name='cloud'),
]
\ No newline at end of file
from django.views.generic.base import TemplateView
from . import templates
from django.shortcuts import render
# Create your views here.
# Create your views here.
class HeroesView(TemplateView):
template_name = 'heroes.html'
class JesterView(TemplateView):
template_name = 'detail_jester.html'
class CloudView(TemplateView):
template_name = 'detail_cloud.html'
class SunfloweyView(TemplateView):
template_name = 'detail_sunflowey.html'
......@@ -19,21 +19,18 @@ class NewVisitorTest(unittest.TestCase):
# She sees a list containing three heroes with their corresponding
# names, health points, and damage
character_name = self.browser.find_element_by_tag_name('h1').text
health_points = self.browser.find_element_by_tag_name('dt').text
damage_points = self.browser.find_element_by_tag_name('dt').text
self.assertIn('Jester', character_name)
self.assertIn('660', health_points)
self.assertIn('64', damage_points)
self.assertIn('Jester', self.browser.find_element_by_id('jester').text)
self.assertIn('660', self.browser.find_element_by_id('hp-jester').text)
self.assertIn('64', self.browser.find_element_by_id('d-jester').text)
self.assertIn('Cloud', character_name)
self.assertIn('600', health_points)
self.assertIn('57', damage_points)
self.assertIn('Cloud', self.browser.find_element_by_id('cloud').text)
self.assertIn('600', self.browser.find_element_by_id('hp-cloud').text)
self.assertIn('57', self.browser.find_element_by_id('d-cloud').text)
self.assertIn('Sunflowey', character_name)
self.assertIn('650', health_points)
self.assertIn('43', damage_points)
self.assertIn('Sunflowey', self.browser.find_element_by_id('sunflowey').text)
self.assertIn('650', self.browser.find_element_by_id('hp-sunflowey').text)
self.assertIn('43', self.browser.find_element_by_id('d-sunflowey').text)
# When she selects one of the heroes, she is sent to another page
......@@ -42,7 +39,6 @@ class NewVisitorTest(unittest.TestCase):
link.click()
# She spots the page title and header mentions the name of the hero she selected.
self.assertEquals('http://localhost:8000/hero/Jester', self.browser.current_url)
self.assertIn('Detail - Jester', self.browser.title)
self.assertIn('Detail - Jester', self.browser.find_element_by_tag_name('h1').text)
......@@ -50,8 +46,39 @@ class NewVisitorTest(unittest.TestCase):
# She clicks this and she is redirected back to the wiki's homepage.
homePageLink = self.browser.find_element_by_link_text('Back to Heroes List')
homePageLink.click()
# When she selects one of the heroes, she is sent to another page
# containing more information about the hero (additional stats, lore, image).
link = self.browser.find_element_by_link_text('Cloud')
link.click()
# 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.find_element_by_tag_name('h1').text)
# 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.
homePageLink = self.browser.find_element_by_link_text('Back to Heroes List')
homePageLink.click()
# When she selects one of the heroes, she is sent to another page
# containing more information about the hero (additional stats, lore, image).
link = self.browser.find_element_by_link_text('Sunflowey')
link.click()
# She spots the page title and header mentions the name of the hero she selected.
self.assertIn('Detail - Sunflowey', self.browser.title)
self.assertIn('Detail - Sunflowey', self.browser.find_element_by_tag_name('h1').text)
# 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.
homePageLink = self.browser.find_element_by_link_text('Back to Heroes List')
homePageLink.click()
self.fail('Finish the test!')
if __name__ == '__main__':
unittest.main(warnings='ignore')
\ No newline at end of file
......@@ -37,6 +37,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'heroes',
]
MIDDLEWARE = [
......@@ -54,7 +55,9 @@ ROOT_URLCONF = 'willowisp.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [
'templates'
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
......@@ -118,3 +121,7 @@ USE_TZ = True
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'heroes/static')
]
......@@ -14,8 +14,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
]
path('', include('heroes.urls')),
]
\ 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