Commit cce3522d authored by Coltrane Torres's avatar Coltrane Torres

Initial commit

parents
Pipeline #937 failed with stages
File added
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>
<head>
<title>Detail - Cloud</title>
</head>
<body>
<div id = "cloud" >
<img src="{% static 'heroes/templates/cloud.png' %}" alt ='Cloud' style="width: 10vw;" />
<h1>Detail - Cloud</h1>
<dl>
<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>
<button type="button" onclick = "location.href='http://localhost:8000/heroes'">Back to Heroes List</button>
</dl>
</body>
</html>
\ No newline at end of file
{% load static %}
<!DOCTYPE html>
<html>
<head>
<title>Detail - Jester</title>
</head>
<body>
<div id = "jester">
<img src= "{% static 'heroes/templates/jester.png' %}" alt='Jester' style="width: 10vw;"/>
<h1>Detail - Jester</h1>
<dl>
<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>
<button type="button" onclick = "location.href='http://localhost:8000/heroes'">Back to Heroes List</button>
</dl>
</body>
</html>
\ No newline at end of file
{% load static %}
<!DOCTYPE html>
<html>
<head>
<title>Detail - Sunflowey</title>
</head>
<body>
<div id = "sunflowey">
<img src= "{% static 'heroes/templates/sunflowey.png' %}" alt='Sunflowey' style="width: 10vw;"/>
<h1>Detail - Sunflowey</h1>
<dl>
<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>
<button type="button" onclick = "location.href='http://localhost:8000/heroes'">Back to Heroes List</button>
</dl>
</body>
</html>
\ No newline at end of file
<html>
<head>
<title>The Will of the Wisps Wiki heroes</title>
</head>
<body>
<div id ="cloud">
<div id ="sunflowey">
<div id ="jester">
<h1>The Will of the Wisps</h1>
<a id = "cloud" href='/hero/cloud'>Cloud</a>
<p>Health Points: 600</p>
<p>Damage: 57</p>
<a id = "sunflowey" href='/hero/sunflowey'>Sunflowey</a>
<p>Health Points: 650</p>
<p>Damage: 43</p>
<a id = "jester" href='/hero/jester'>Jester</a>
<p>Health Points: 660</p>
<p>Damage: 64</p>
</ul>
</body>
</html>
\ No newline at end of file
from django.test import TestCase
from django.urls import resolve
from django.http import HttpRequest
# Create your tests here.
from .views import HeroesView, CloudView, JesterView, SunfloweyView
class HeroesListPageTest(TestCase):
def test_heroes_page(self):
response = self.client.get('/heroes')
self.assertTemplateUsed(response, 'heroes.html';)
def test_cloud_page(self):
response = self.client.get('/hero/cloud/')
self.assertTemplateUsed(response, 'detail_cloud.html')
def test_jester_page(self):
response = self.client.get('/hero/jester/')
self.assertTemplateUsed(response, 'detail_jester.html')
def test_sunflowey_page(self):
response = self.client.get('/hero/sunflowey/')
self.assertTemplateUsed(response, 'detail_sunflowey.html')
\ No newline at end of file
from django.urls import path
from .views import HeroesView, CloudView, SunfloweyView, JesterView
urlpatterns = [
path('heroes', HeroesView.as_view(), name='heroes'),
path('hero/cloud/', CloudView.as_view(), name='hero/cloud'),
path('hero/sunflowey/', SunfloweyView.as_view(), name='hero/sunflowey'),
path('hero/jester/', JesterView.as_view(), name='hero/jester'),
]
\ No newline at end of file
from django.shortcuts import render
from django.views.generic.base import TemplateView
# Create your views here.
class HeroesView(TemplateView):
template_name = "heroes.html"
class CloudView(TemplateView):
template_name = "detail_cloud.html"
class JesterView(TemplateView):
template_name = "detail_jester.html"
class SunfloweyView(TemplateView):
template_name = "detail_sunflowey.html"
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
self.browser.get('http://localhost:8000/heroes')
# 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
#cloud = self.browser.find_element_by_tag_id('cloud')
cloud = self.browser.find_element_by_id('cloud')
self.assertIn('Cloud', cloud.text)
self.assertIn('Health Points:', cloud.text)
self.assertIn('Damage:', cloud.text)
jester = self.browser.find_element_by_id('jester')
self.assertIn('Jester', jester.text)
self.assertIn('Health Points:', jester.text)
self.assertIn('Damage:', jester.text)
sunflowey = self.browser.find_element_by_id('sunflowey')
self.assertIn('Sunflowey', sunflowey.text)
self.assertIn('Health Points:', sunflowey.text)
self.assertIn('Damage:', sunflowey.text)
# When she selects one of the heroes, she is sent to another page
# containing more information about the hero (additional stats, lore, image).
cloud = self.browser.find_element_by_id('cloud')
cloud.click()
self.assertIn('/hero/cloud', self.browser.current_url)
self.assertIn('Cloud', self.browser.title)
self.assertIn('/heroes', self.browser.current_url)
jester = self.browser.find_element_by_id('jester')
jester.click()
self.assertIn('/hero/jester', self.browser.current_url)
self.assertIn('Jester', self.browser.title)
self.assertIn('/heroes', self.browser.current_url)
sunflowey = self.browser.find_element_by_id('sunflowey')
sunflowey.click()
self.assertIn('/hero/sunflowey', self.browser.current_url)
self.assertIn('Sunflowey', self.browser.title)
self.assertIn('/heroes', self.browser.current_url)
# She spots the page title and header mentions the name of the hero she selected.
self.browser.find_element_by_link_text('cloud').click()
self.assertIn('Detail - Cloud', self.browser.title)
header = self.browser.find_element_by_tage_name('head').text
self.assertIn('Detail - Cloud', header)
self.browser.find_element_by_link_text('jester').click()
self.assertIn('Detail - Jester', self.browser.title)
header = self.browser.find_element_by_tage_name('head').text
self.assertIn('Detail - Jester', header)
self.browser.find_element_by_link_text('sunflowey').click()
self.assertIn('Detail - Sunflowey', self.browser.title)
header = self.browser.find_element_by_tage_name('sunflowey').text
self.assertIn('Detail - Sunflowey', header)
# 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.browser.find_element_by_link_text('Back to Heroes List').click()
self.assertIn('The Will of the Wisps Wiki', self.browser.title)
self.browser.find_element_by_link_text('jester').click()
self.browser.find_element_by_link_text('Back to Heroes List').click()
self.browser.get('http://localhost:8000/heroes')
self.browser.find_element_by_link_text('sunflowey').click()
self.browser.find_element_by_link_text('Back to Heroes List').click()
self.browser.get('http://localhost:8000/heroes')
self.fail('Finish the test!')
if _name_ == '_main_':
unittest.main(warnings='ignore')
\ No newline at end of file
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'willowisp.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
"""
ASGI config for willowisp project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'willowisp.settings')
application = get_asgi_application()
"""
Django settings for willowisp project.
Generated by 'django-admin startproject' using Django 3.0.4.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '0-j4b@7z(#r%9g99#j%d(bh2uu*u0c%267w(@1a3x6e#5@$2xs'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'heroes'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'willowisp.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'willowisp.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'willowisp',
'USER': 'postgres',
'PASSWORD': 'apocalypto',
'HOST': 'localhost',
'PORT': '5432',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/'
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'',include('heroes.urls')),
]
"""
WSGI config for willowisp project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'willowisp.settings')
application = get_wsgi_application()
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