Source

FluidInYourEar / fluidocalypse / tests / twill_tests / functional_tests.twill

Full commit
# Functional Tests for Fluid In Your Ear written with Twill
#
# These are pretty crude at the moment, but form a useful
# foundation to begin testing the core functionality of the
# application
#
# You will need to ensure the Django development server is
# running

# ############################################################
# test calls to root URL goes to genre search page
# ############################################################

# test without trailing slash
go http://127.0.0.1:8000
code 200
url http://127.0.0.1:8000/search/genre

# test with trailing slash
go http://127.0.0.1:8000
code 200
url http://127.0.0.1:8000/search/genre

# ############################################################
# test calls to genre search page
# ############################################################

# test with trailing slash
go http://127.0.0.1:8000/search/genre/
code 200

# test without trailing slash
go http://127.0.0.1:8000/search/genre
code 200

# check form - crude tests
find '<form action="" method="post" name="search_form">'
find '<select name="genre">'
find '<option value="grindcore">Grindcore</option>'
find '</select>'
find '<input type="submit" value="Show genre" />'

# test form
formvalue search_form genre grindcore
submit
code 200
url http://127.0.0.1:8000/genre/grindcore

# ############################################################
# test calls to genre pages
# ############################################################

# test missing genre
go http://127.0.0.1:8000/genre/progressive_vegetarian_grindcore
code 404

# test with trailing slash
go http://127.0.0.1:8000/genre/jazz/
code 200

# test without trailing slash
go http://127.0.0.1:8000/genre/jazz
code 200

# check page contents
find '<h2 class="heading">Jazz</h2>'
find '<div id="related_bands">'
find '<li><a href="/band/Frank%20Zappa">Frank Zappa</a></li>'

find '<div id="related_genres">'
find '<h3 class="heading">Related Genres</h3>'
find '<span style="font-size: [.0-9]+em; white-space: nowrap; padding: [.0-9]+em;"><a href="/genre/avant_garde_music">Avant-garde music</a></span>'

# ############################################################
# test calls to band pages
# ############################################################

# test missing band
go http://127.0.0.1:8000/band/hgshfgahgsfhaghsf
code 404

# test with trailing slash - NOTE: broken, need to fix
go http://127.0.0.1:8000/band/Napalm%20Death/
code 200

# test without trailing slash
go http://127.0.0.1:8000/band/Napalm%20Death
code 200

# check page contents
find '<h2 class="heading">Napalm Death</h2>'
find '<p><a href="http://en.wikipedia.org/wiki/Napalm_Death" target="_blank">Wikipedia Entry</a></p>'

find '<div id="related_bands">'
find '<li><a href="/band/Benediction">Benediction</a></li>'

find '<div id="related_genres">'
find '<h3 class="heading">Related Genres</h3>'
find '<li><a href="/genre/crust_punk">Crust punk</a></li>'

# Test the URL of the legendary dronesters
go http://127.0.0.1:8000/band/Sunn%20O)))
code 200

# ############################################################
# test calls to band search page
# band search page is very slow
# ############################################################

# test with trailing slash
go http://127.0.0.1:8000/search/band/
code 200

# test without trailing slash
go http://127.0.0.1:8000/search/band
code 200

# check form - crude tests
find '<form action="" method="post" name="search_form">'
find '<select name="band">'
find '<option value="Napalm Death">Napalm Death</option>'
find '</select>'
find '<input type="submit" value="Show band" />'

# test form
formvalue search_form band "Napalm Death"
submit
code 200
url http://127.0.0.1:8000/band/Napalm%20Death