Style fixes in test_functional.py.
[Melange.git] / tests / test_functional.py
blob00c54704a8ec62aca795970dd8d38881d97ba3a3
1 #!/usr/bin/python2.5
3 # Copyright 2009 the Melange authors.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 __authors__ = [
19 '"Matthew Wilkes" <matthew@matthewwilkes.co.uk>',
23 from gaeftest.test import FunctionalTestCase
25 from zope.testbrowser import browser
27 import os.path
30 class MelangeFunctionalTestCase(FunctionalTestCase):
31 """A base class for all functional tests in Melange.
33 Tests MUST NOT be defined here, but the superclass requires a path
34 attribute that points to the app.yaml. Utility functions MAY be
35 declared here to be shared by all functional tests, but any
36 overridden unittest methods MUST call the superclass version.
37 """
39 path = os.path.abspath(__file__+"/../../app/app.yaml")
42 class TestBranding(MelangeFunctionalTestCase):
43 """Tests that ensure Melange properly displays attribution.
45 Other notices, as required by the project and/or law, are tested
46 here as well.
47 """
49 def test_attribution(self):
50 """Ensure that the front page asserts that it is a Melange app.
51 """
53 tb = browser.Browser()
54 tb.open("http://127.0.0.1:8080/site/show/site")
56 self.assertTrue("Powered by Melange" in tb.contents)
59 class TestLogin(MelangeFunctionalTestCase):
60 """Tests that check the login system is functioning correctly.
62 Also tests that users go through the correct registration workflow.
63 """
65 def test_firstLogin(self):
66 """Ensure that new users are prompted to create a profile.
68 Also test that only new users are prompted.
69 """
71 tb = browser.Browser()
72 tb.open("http://127.0.0.1:8080")
74 tb.getLink("Sign in").click()
75 self.assertTrue("login" in tb.url)
77 # fill in dev_appserver login form
78 tb.getForm().getControl("Email").value = "newuser@example.com"
79 tb.getForm().getControl("Login").click()
81 self.assertTrue(tb.url.endswith("/show/site"))
82 self.assertTrue('Please create <a href="/user/create_profile">'
83 'User Profile</a> in order to view this page' in tb.contents)
85 tb.getLink("User Profile").click()
87 # fill in the user profile
88 cp = tb.getForm(action="create_profile")
89 cp.getControl(name="link_id").value = "exampleuser"
90 cp.getControl(name="name").value = "Example user"
91 cp.getControl("Save").click()
93 # if all is well, we go to the edit page
94 self.assertTrue("edit_profile" in tb.url)
96 tb.open("http://127.0.0.1:8080")
98 # call to action no longer on front page
99 self.assertFalse('Please create <a href="/user/create_profile">'
100 'User Profile</a> in order to view this page' in tb.contents)