source: products/quintagroup.seoptimizer/branches/refactoring2.3.0/quintagroup/seoptimizer/tests/browser.txt @ 1833

Last change on this file since 1833 was 1833, checked in by mylan, 14 years ago

#161: Clarify, fix installation/uninstallation tests overheads

File size: 4.7 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.getLink('Log in').click()
38    >>> browser.url
39    'http://nohost/plone/login_form'
40    >>> browser.getControl('Login Name').value = portal_owner
41    >>> browser.getControl('Password').value = default_password
42    >>> browser.getControl('Log in').click()
43    >>> "You are now logged in" in browser.contents
44    True
45    >>> "Login failed" in browser.contents
46    False
47    >>> browser.url
48    'http://nohost/plone/login_form'
49
50
51-*- extra stuff goes here -*-
52Test 'SEO Properties' action
53===============================
54
55First uninstall product, if it is already installed:
56
57    >>> from quintagroup.seoptimizer.config import PROJECT_NAME
58    >>> self.qi = self.portal.portal_quickinstaller
59    >>> if self.qi.isProductInstalled(PROJECT_NAME):
60    ...     self.qi.uninstallProducts([PROJECT_NAME,])
61
62
63Test installation 'SEO Properties' action
64
65    >>> browser.open('http://nohost/plone/front-page')
66    >>> "SEO Properties" in browser.contents
67    False
68    >>> self.qi.installProduct(PROJECT_NAME)
69    'Ran all install steps.'
70    >>> self.sp = self.portal.portal_properties.seo_properties
71    >>> self.object_tabs = self.portal.portal_actions.object
72    >>> self.portal.portal_actions.object.get('SEOProperties', None) is not None
73    True
74
75Test visibility 'SEO Properties' action after installation
76
77    >>> self.sp.content_types_with_seoproperties = ('Document',)
78    >>> browser.open('http://nohost/plone/front-page')
79    >>> "SEO Properties" in browser.contents
80    True
81    >>> browser.getLink('SEO Properties').url
82    'http://nohost/plone/front-page/@@seo-context-properties'
83
84Test invisibility 'SEO Properties' action after installation
85
86    >>> self.sp.content_types_with_seoproperties = ('File',)
87    >>> browser.open('http://nohost/plone/front-page')
88    >>> "SEO Properties" in browser.contents
89    False
90
91Test reinstallation 'SEO Properties' action
92
93    >>> browser.open('http://nohost/plone/front-page')
94    >>> "SEO Properties" in browser.contents
95    False
96    >>> self.qi.reinstallProducts((PROJECT_NAME,))
97    >>> self.portal.portal_actions.object.get('SEOProperties', None) is not None
98    True
99
100Test visibility 'SEO Properties' action after reinstallation
101
102    >>> self.sp.content_types_with_seoproperties = ('Document',)
103    >>> browser.open('http://nohost/plone/front-page')
104    >>> "SEO Properties" in browser.contents
105    True
106    >>> browser.getLink('SEO Properties').url
107    'http://nohost/plone/front-page/@@seo-context-properties'
108
109Test invisibility 'SEO Properties' action after reinstallation
110
111    >>> self.sp.content_types_with_seoproperties = ('File',)
112    >>> browser.open('http://nohost/plone/front-page')
113    >>> "SEO Properties" in browser.contents
114    False
115
116Test uninstallation 'SEO Properties' action
117
118    >>> self.sp.content_types_with_seoproperties = ('Document',)
119    >>> browser.open('http://nohost/plone/front-page')
120    >>> "SEO Properties" in browser.contents
121    True
122    >>> self.qi.uninstallProducts((PROJECT_NAME,))
123    >>> self.portal.portal_actions.object.get('SEOProperties', None) is not None
124    False
125
126Test visibility 'SEO Properties' action after uninstallation
127
128    >>> self.sp.content_types_with_seoproperties = ('Document',)
129    >>> browser.open('http://nohost/plone/front-page')
130    >>> "SEO Properties" in browser.contents
131    False
Note: See TracBrowser for help on using the repository browser.