Created
January 30, 2013 20:45
-
-
Save wesrog/4676770 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from base import BaseTestCase | |
from tests.lib.actions import HtmlDocument, click_link, click_button, fill_in | |
from tests.lib.exceptions import LinkNotFound, ButtonNotFound, InputNotFound | |
from werkzeug.wrappers import Response | |
class TestLibActions(BaseTestCase): | |
def test_click_link(self): | |
self.assertEqual(click_link(response, 'Explore Releases'), '/releases') | |
self.assertRaises(LinkNotFound, click_link, response, 'wat') | |
def test_click_button(self): | |
self.assertEqual( | |
click_button(response, 'Create Account')['action'], | |
'/users/new' | |
) | |
self.assertRaises(ButtonNotFound, click_button, response, 'wat') | |
def test_fill_in(self): | |
self.assertIn( | |
'[email protected]', | |
fill_in(response, 'Email', '[email protected]') | |
) | |
self.assertRaises(InputNotFound, fill_in, response, 'First Name') | |
response = Response(''' | |
<html> | |
<head> | |
<title>Discogs</title> | |
</head> | |
<body> | |
<h1>Discogs</h1> | |
<p><a href="/releases">Explore Releases</a></p> | |
<form action="/users/new" method="post"> | |
<p> | |
<label for="email">Email</label> | |
<input type="text" name="email" id="email" /> | |
</p> | |
<p> | |
<label for="password">Password</label> | |
<input type="password" name="password" id="password" /> | |
</p> | |
<p> | |
<input type="submit" value="Create Account" /> | |
</p> | |
</form> | |
</body> | |
</html> | |
''') | |
doc = HtmlDocument(response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment