source: products/quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/tests/seo_properties.txt @ 3233

Last change on this file since 3233 was 3233, checked in by vmaksymiv, 13 years ago

added plone4.1 compatibility

  • Property svn:eol-style set to native
File size: 3.6 KB
Line 
1Introduction
2============
3
4This is a full-blown functional test. The emphasis here is on testing what
5the user may input and see, and the system is largely tested as a black box.
6We use PloneTestCase to set up this test as well, so we have a full Plone site
7to play with. We *can* inspect the state of the portal, e.g. using
8self.portal and self.folder, but it is often frowned upon since you are not
9treating the system as a black box. Also, if you, for example, log in or set
10roles using calls like self.setRoles(), these are not reflected in the test
11browser, which runs as a separate session.
12
13Being a doctest, we can tell a story here.
14
15First, we must perform some setup. We use the testbrowser that is shipped
16with Five, as this provides proper Zope 2 integration. Most of the
17documentation, though, is in the underlying zope.testbrower package.
18
19    >>> from Products.Five.testbrowser import Browser
20    >>> browser = Browser()
21    >>> portal_url = self.portal.absolute_url()
22
23The following is useful when writing and debugging testbrowser tests. It lets
24us see all error messages in the error_log.
25
26    >>> self.portal.error_log._ignored_exceptions = ()
27
28With that in place, we can go to the portal front page and log in. We will
29do this using the default user from PloneTestCase:
30
31    >>> from Products.PloneTestCase.setup import portal_owner, default_password
32    >>> browser.open(portal_url)
33
34We have the login portlet, so let's use that.
35
36    >>> browser.open('http://nohost/plone/login_form')
37    >>> browser.getControl('Login Name').value = portal_owner
38    >>> browser.getControl('Password').value = default_password
39    >>> browser.getControl('Log in').click()
40    >>> "You are now logged in" in browser.contents
41    True
42    >>> "Login failed" in browser.contents
43    False
44    >>> browser.url
45    'http://nohost/plone/login_form'
46
47
48-*- extra stuff goes here -*-
49Test 'SEO Properties' in action
50===============================
51
52Let's define some helpfull variables:
53
54    >>> page = self.portal["front-page"]
55    >>> page_url = page.absolute_url()
56    >>> seoprops_url = page_url + "/@@seo-context-properties"
57
58Test wheter 'SEO Properties' tab is visible on front page or not.
59
60    >>> browser.open(page_url)
61    >>> "SEO Properties" in browser.contents
62    True
63
64Now, let's go to the "SEO Properties" page, make some changes
65and click on "Cansel" button.
66
67    >>> browser.open(seoprops_url)
68    >>> browser.getControl(name="seo_description_override").value = True
69    >>> descr_ctrl = browser.getControl(name="seo_description")
70    >>> descr_ctrl.value = "Test change of SEO description"
71    >>> browser.getControl("Cancel").click()
72    >>> cancel_page = browser.contents
73    >>> file("/tmp/seo_props.cancel.html","wb").write(cancel_page)
74
75Clicking on "Cancel" button should lead us to the front-page view.
76
77    >>> browser.url == page_url
78    True
79
80No changes must be applied.
81
82    >>> not "Test change of SEO description" in cancel_page
83    True
84
85Check whether status message is correct or not?
86
87    >>> "No content SEO properties have been changed." in cancel_page
88    True
89
90
91Let's review other situation. Go to the "SEO Properties" page, make some changes
92and click on "Save" button.
93
94    >>> browser.open(seoprops_url)
95    >>> browser.getControl(name="seo_description_override").value = True
96    >>> descr_ctrl = browser.getControl(name="seo_description")
97    >>> descr_ctrl.value = "Test change of SEO description"
98    >>> browser.getControl("Save").click()
99    >>> save_page = browser.contents
100
101No changes must be applied.
102
103    >>> "Test change of SEO description" in save_page
104    True
105
106Check whether status message is correct or not?
107
108    >>> "Content SEO properties have been saved" in save_page
109    True
Note: See TracBrowser for help on using the repository browser.