Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
Lab_1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayn Collado
Lab_1
Commits
ba13a9c1
Commit
ba13a9c1
authored
Mar 09, 2020
by
Ayn Collado
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
I finished it
parent
729c5ab3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
20 deletions
+33
-20
.gitignore
.gitignore
+2
-0
tests.py
heroes/tests.py
+28
-17
detail_cloud.html
templates/detail_cloud.html
+1
-1
detail_jester.html
templates/detail_jester.html
+1
-1
detail_sunflowey.html
templates/detail_sunflowey.html
+1
-1
No files found.
.gitignore
View file @
ba13a9c1
...
...
@@ -6496,3 +6496,5 @@ myenv/Scripts/winsound.pyd
myenv/Scripts/__pycache__/django-admin.cpython-38.pyc
.vscode/launch.json
.vscode/launch.json
heroes/geckodriver.log
heroes/__pycache__/tests.cpython-38.pyc
heroes/tests.py
View file @
ba13a9c1
from
selenium
import
webdriver
from
django.urls
import
resolve
from
.views
import
home_page
import
unittest
class
NewVisitorTest
(
unittest
.
TestCase
):
...
...
@@ -12,14 +13,13 @@ class NewVisitorTest(unittest.TestCase):
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'
)
# She notices the page title and header mention
# 'The Will of the Wisps Wiki'
self
.
browser
.
get
(
'http://localhost:8000/heroes'
)
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
def
test_cloud_in_home_page
(
self
):
self
.
browser
.
get
(
'http://localhost:8000'
)
detail
=
self
.
browser
.
find_element_by_id
(
'cloud_name'
)
self
.
assertEqual
(
detail
.
get_attribute
(
'innerHTML'
),
'Cloud'
)
detail
=
self
.
browser
.
find_element_by_id
(
'cloud_hp'
)
...
...
@@ -27,6 +27,8 @@ class NewVisitorTest(unittest.TestCase):
detail
=
self
.
browser
.
find_element_by_id
(
'cloud_ad'
)
self
.
assertEqual
(
detail
.
get_attribute
(
'innerHTML'
),
'57'
)
def
test_sunflowey_in_home_page
(
self
):
self
.
browser
.
get
(
'http://localhost:8000'
)
detail
=
self
.
browser
.
find_element_by_id
(
'sunflowey_name'
)
self
.
assertEqual
(
detail
.
get_attribute
(
'innerHTML'
),
'Sunflowey'
)
detail
=
self
.
browser
.
find_element_by_id
(
'sunflowey_hp'
)
...
...
@@ -34,6 +36,8 @@ class NewVisitorTest(unittest.TestCase):
detail
=
self
.
browser
.
find_element_by_id
(
'sunflowey_ad'
)
self
.
assertEqual
(
detail
.
get_attribute
(
'innerHTML'
),
'43'
)
def
test_jester_in_home_page
(
self
):
self
.
browser
.
get
(
'http://localhost:8000'
)
detail
=
self
.
browser
.
find_element_by_id
(
'jester_name'
)
self
.
assertEqual
(
detail
.
get_attribute
(
'innerHTML'
),
'Jester'
)
detail
=
self
.
browser
.
find_element_by_id
(
'jester_hp'
)
...
...
@@ -42,23 +46,30 @@ class NewVisitorTest(unittest.TestCase):
self
.
assertEqual
(
detail
.
get_attribute
(
'innerHTML'
),
'64'
)
# When she selects one of the heroes, she is sent to another page
# containing more information about the hero (additional stats, lore, image).
def
test_cloud_check_title_and_heading
(
self
):
self
.
browser
.
get
(
'http://localhost:8000/hero/cloud'
)
self
.
browser
.
get
(
'http://localhost:8000/hero/sunflowey'
)
self
.
browser
.
get
(
'http://localhost:8000/hero/jester'
)
# She spots the page title and header mentions the name of the hero she selected.
detail
=
self
.
browser
.
find_element_by_id
(
'cloud_title'
)
self
.
assertEqual
(
detail
.
get_attribute
(
'innerHTML'
),
'Detail - Cloud'
)
self
.
assertIn
(
'Detail - Cloud'
,
self
.
browser
.
title
)
detail
=
self
.
browser
.
find_element_by_id
(
'cloud_heading'
)
self
.
assertEqual
(
detail
.
get_attribute
(
'innerHTML'
),
'Detail - Cloud'
)
# 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.
button
=
self
.
browser
.
find_element_by_id
(
'back_button'
)
self
.
assertEqual
(
button
.
get_attribute
(
'innerHTML'
),
'Back to Heroes List'
)
def
test_sunflowey_check_title_and_heading
(
self
):
self
.
browser
.
get
(
'http://localhost:8000/hero/sunflowey'
)
self
.
assertIn
(
'Detail - Sunflowey'
,
self
.
browser
.
title
)
detail
=
self
.
browser
.
find_element_by_id
(
'sunflowey_heading'
)
self
.
assertEqual
(
detail
.
get_attribute
(
'innerHTML'
),
'Detail - Sunflowey'
)
def
test_jester_check_title_and_heading
(
self
):
self
.
browser
.
get
(
'http://localhost:8000/hero/jester'
)
self
.
assertIn
(
'Detail - Jester'
,
self
.
browser
.
title
)
detail
=
self
.
browser
.
find_element_by_id
(
'jester_heading'
)
self
.
assertEqual
(
detail
.
get_attribute
(
'innerHTML'
),
'Detail - Jester'
)
def
check_button
(
self
):
homeButton
=
self
.
browser
.
find_element_by_id
(
'homeButton'
)
.
click
()
self
.
assertEqual
(
resolve
(
'/'
)
.
func
,
home_page
)
def
test_pass
(
self
):
self
.
fail
(
'Finish the test!'
)
if
__name__
==
'__main__'
:
unittest
.
main
(
warnings
=
'ignore'
)
\ No newline at end of file
templates/detail_cloud.html
View file @
ba13a9c1
<!DOCTYPE html>
<html>
<head>
<title
id=
'cloud_title'
>
Detail - Cloud
</title>
<title>
Detail - Cloud
</title>
</head>
<body>
<img
src=
"https://opengameart.org/sites/default/files/styles/medium/public/bigvioletcloud_0.png"
style=
"width: 10vw;"
/>
...
...
templates/detail_jester.html
View file @
ba13a9c1
<!DOCTYPE html>
<html>
<head>
<title
id=
'jester_title'
>
Detail - Jester
</title>
<title>
Detail - Jester
</title>
</head>
<body>
<img
src=
"https://opengameart.org/sites/default/files/styles/medium/public/jester.png"
style=
"width: 10vw;"
/>
...
...
templates/detail_sunflowey.html
View file @
ba13a9c1
<!DOCTYPE html>
<html>
<head>
<title
id=
'sunflowey_title'
>
Detail - Sunflowey
</title>
<title>
Detail - Sunflowey
</title>
</head>
<body>
<img
src=
"https://opengameart.org/sites/default/files/styles/medium/public/sunflower_plant_enemy_game_character_sprites.jpg"
style=
"width: 10vw;"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment