[CMF-checkins] CVS: CMF/functest/visitor - advanced_search.zft:1.1 become_member.zft:1.1 browse_homepage.zft:1.1 browse_news.zft:1.1 browse_topic.zft:1.1 log_in.zft:1.1 provide_feedback.zft:1.1 quick_search.zft:1.1 scaffolding.py:1.1
Tres Seaver
tseaver@zope.com
Thu, 29 Aug 2002 19:05:41 -0400
Update of /cvs-repository/CMF/functest/visitor
In directory cvs.zope.org:/tmp/cvs-serv13211/visitor
Added Files:
advanced_search.zft become_member.zft browse_homepage.zft
browse_news.zft browse_topic.zft log_in.zft
provide_feedback.zft quick_search.zft scaffolding.py
Log Message:
- Move functional tests here from FunctionalTests library examples.
=== Added File CMF/functest/visitor/advanced_search.zft ===
[Scenario]
Title : Advanced Search
Use_case: Search CMF Site
[Setup]
Filename: %(config_dir)s/scaffolding.py
Function: advanced_search_setup
[Search_form]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/search_form
Expected_Result: 200
[Q_text]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/search?SearchableText=content&Title=&Description=&created:date=1970/01/01+00:00:00+GMT&created_usage=range:min&Creator=
Expected_Result: 200
[Q_subject]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/search?SearchableText=&Title=&Subject:list=Bar&Description=&created:date=1970/01/01+00:00:00+GMT&created_usage=range:min&Creator=
Expected_Result: 200
[Q_title]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/search?SearchableText=&Title=test&Description=&created:date=1970/01/01+00:00:00+GMT&created_usage=range:min&Creator=
Expected_Result: 200
[Click_through]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/%(click_through_id)s/view
Expected_Result: 200
[Q_created]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/search?SearchableText=&Title=&Description=&created:date=2001/11/11&created_usage=range:min&Creator=
Expected_Result: 200
[Q_type]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/search?SearchableText=&Title=&Description=&created:date=1970/01/01+00:00:00+GMT&created_usage=range:min&Type:list=Document&Creator=
Expected_Result: 200
[Q_creator]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/search?SearchableText=&Title=&Description=&created:date=1970/01/01+00:00:00+GMT&created_usage=range:min&Creator=test_user
Expected_Result: 200
[Teardown]
Filename: %(config_dir)s/scaffolding.py
Function: advanced_search_teardown
[DEFAULT]
click_through_type: News Item
click_through_id: test_news
=== Added File CMF/functest/visitor/become_member.zft ===
[Scenario]
Title : Become a Member
Use_case: Become a Member
[Setup]
Filename: %(config_dir)s/scaffolding.py
Function: become_member_setup
[HomePage]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s
Expected_Result: 200
[JoinForm]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/join_form
Expected_Result: 200
[Join]
HTTP_Verb: POST
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/register
Field_1: last_visit:date=2001/11/12 17:21:03.25675 US/Eastern
Field_2: prev_visit:date=2001/11/12 17:21:03.25737 US/Eastern
Field_3: username=test_user
Field_4: email=test_user@zope.com
Field_5: password=xyzzy
Field_6: confirm=xyzzy
Field_7: submit=Register
Expected_Result: 200
[Postcondition]
Filename: %(config_dir)s/scaffolding.py
Function: become_member_postcondition
[Teardown]
Filename: %(config_dir)s/scaffolding.py
Function: become_member_teardown
=== Added File CMF/functest/visitor/browse_homepage.zft ===
[Scenario]
Title : Browse Site Homepage
Use_case: Browse Site Homepage
[Homepage]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s
Expected_Result: 200
=== Added File CMF/functest/visitor/browse_news.zft ===
[Scenario]
Title : Browse Site News
Use_case: Browse Site News
[Setup]
Filename: %(config_dir)s/scaffolding.py
Function: browse_news_setup
[Homepage]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s
Expected_Result: 200
[NewsPage]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/recent_news
Expected_Result: 200
[NewsItem]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/test_news
Expected_Result: 200
[Teardown]
Filename: %(config_dir)s/scaffolding.py
Function: browse_news_teardown
=== Added File CMF/functest/visitor/browse_topic.zft ===
[Scenario]
Title : Browse Topic
Use_case: Browse Topic
[Setup]
Filename: %(config_dir)s/scaffolding.py
Function: browse_topic_setup
[Home_page]
URL: %(portal_url)s/%(site_path)s
Expected_Result: 200
[Topic_view]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/%(topic_id)s
Expected_Result: 200
[ClickThrough]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/%(click_through_id)s
Expected_Result: 200
[Teardown]
Filename: %(config_dir)s/scaffolding.py
Function: browse_topic_teardown
[DEFAULT]
userid: test_user
password: xyzzy
click_through_id: test_news
click_through_Type: News Item
topic_crit_value: News Item
topic_crit_field: Type
topic_id: test_topic
=== Added File CMF/functest/visitor/log_in.zft ===
[Scenario]
Title : Log in to the site (Cookie Crumbler)
Use_case: Log in
[Setup]
Filename: %(config_dir)s/scaffolding.py
Function: log_in_setup
[My_stuff_xxx]
URL: %(portal_url)s/%(site_path)s/Members/%(userid)s/folder_contents
Expected_Result: 302
Expected_Redirect: %(portal_url)s/%(site_path)s/login_form
[Login_form]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/login_form
Expected_Result: 200
[Logged_in]
HTTP_Verb: POST
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/logged_in
Field_1: %(doh)sac_name:string=%(userid)s
Field_2: %(doh)sac_password:string=%(password)s
Expected_Result: 200
[My_stuff]
URL: %(portal_url)s/%(site_path)s/Members/%(userid)s/folder_contents
Authentication: %(userid)s:%(password)s
Expected_Result: 200
[Teardown]
Filename: %(config_dir)s/scaffolding.py
Function: log_in_teardown
[DEFAULT]
userid: test_user
password: xyzzy
doh=__
=== Added File CMF/functest/visitor/provide_feedback.zft ===
[Scenario]
Title : Provide Feedback on Content
Use_case: Provide Feedback on Content
[Setup]
Filename: %(config_dir)s/scaffolding.py
Function: provide_feedback_setup
[HomePage]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s
Expected_Result: 200
[LoginForm]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/login_form
Expected_Result: 200
[LogIn]
HTTP_Verb: POST
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/logged_in
Field_1: __ac_name=test_user
Field_2: __ac_password=xyzzy
Field_3: __ac_persistent=1
Field_4: submit= Login
Expected_Result: 200
[HomePage_loggedIn]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s
Expected_Result: 200
[NewsItem_1]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/test_news
Authentication: %(userid)s:%(password)s
Field_1: %(doh)sac_name:string=%(userid)s
Field_2: %(doh)sac_password:string=%(password)s
Expected_Result: 200
[ReplyForm_1]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
Authentication: %(userid)s:%(password)s
URL: %(portal_url)s/%(site_path)s/test_news/discussion_reply_form
Expected_Result: 200
[AddReply_1]
HTTP_Verb: POST
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/test_news/talkback
Authentication: %(userid)s:%(password)s
Field_1: title=This is a test
Field_2: text=How beautiful upon the hills are the feet of them
that bring good tidings!
Field_3: title_override=This is a test
Field_4: text_override=How beautiful upon the hills are the feet of them
that bring good tidings!
Field_5: Creator=test_user
Field_6: discussion_reply:method=Reply
Expected_Result: 302
[NewsItem_2]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/test_news/newsitem_view
Authentication: %(userid)s:%(password)s
Expected_Result: 200
# WAAAA! How are we going to test nested replies, when the URLs have
# timestamps?
#
#[Preview_1]
#HTTP_Verb: POST
#HTTP_Version: HTTP/1.0
#URL: %(portal_url)s/%(site_path)s/test_news/talkback
#Authentication: %(userid)s:%(password)s
#Field_1: Creator=test_user
#Field_2: title=This is a test
#Field_3: text=How beautiful upon the hills are the feet of them
# that bring good tidings!
#Field_4: discussion_reply_preview:method=Preview
#Expected_Result: 200
#
#[Request_018]
#HTTP_Verb: GET
#HTTP_Version: HTTP/1.0
#URL: %(portal_url)s/%(site_path)s/test_news/talkback/1005604371
#Expected_Result: 200
#
#[Request_020]
#HTTP_Verb: GET
#HTTP_Version: HTTP/1.0
#URL: %(portal_url)s/%(site_path)s/test_news/talkback/1005604371/discussion_reply_form
#Expected_Result: 200
#
#[Request_022]
#HTTP_Verb: POST
#HTTP_Version: HTTP/1.0
#URL: %(portal_url)s/%(site_path)s/test_news/talkback/1005604371/talkback
#Field_1: Creator=test_user
#Field_2: title=This is a test
#Field_3: text=My love is like a red, red rose.
#Field_4: discussion_reply:method=Reply
#Expected_Result: 200
#
#[Request_023]
#HTTP_Verb: GET
#HTTP_Version: HTTP/1.0
#URL: %(portal_url)s/%(site_path)s/test_news/talkback/1005604371/discussionitem_view
#Expected_Result: 200
#
#[Request_024]
#HTTP_Verb: GET
#HTTP_Version: HTTP/1.0
#URL: %(portal_url)s/%(site_path)s/test_news
#Expected_Result: 200
#
#[Request_026]
#HTTP_Verb: GET
#HTTP_Version: HTTP/1.0
#URL: %(portal_url)s/%(site_path)s/test_news?tree-e=eJyLVneEAl9PC1t1HQUE39fRVj0WAICLB9Q
#Expected_Result: 200
[Postcondition]
Filename: %(config_dir)s/scaffolding.py
Function: provide_feedback_postcondition
[Teardown]
Filename: %(config_dir)s/scaffolding.py
Function: provide_feedback_teardown
[DEFAULT]
userid: test_user
password: xyzzy
doh=__
=== Added File CMF/functest/visitor/quick_search.zft ===
[Scenario]
Title : Quick Search
Use_case: Quick Search
[Setup]
Filename: %(config_dir)s/scaffolding.py
Function: quick_search_setup
[Home_page]
URL: %(portal_url)s/%(site_path)s
Expected_Result: 200
[Search_ok]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/search?SearchableText=content
Expected_Result: 200
[ClickThrough]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/Members/test_user/index_html/view
Authentication: %(userid)s:%(password)s
Expected_Result: 200
[Search_none]
HTTP_Verb: GET
HTTP_Version: HTTP/1.0
URL: %(portal_url)s/%(site_path)s/search?SearchableText=zigabenyi&go.x=5&go.y=8
Expected_Result: 200
[Teardown]
Filename: %(config_dir)s/scaffolding.py
Function: quick_search_teardown
[DEFAULT]
userid: test_user
password: xyzzy
=== Added File CMF/functest/visitor/scaffolding.py ===
"""
Scaffolding methods for CMF_base visitor tests.
- "setup" methods should return boolean "OK to continue" values.
- "postcondition" methods should return boolean "test succeeded" values.
- "teardown" methods don't need to return anything at all.
Methods can assume that Zope has been imported; they may not (yet)
import any Zope-specific packages or modules.
Each method will be passed a handle to the root Zope object ('app'),
a dictionary ('test_vars') containing the "defaults" used in
constructing the functional tests, and the result object (useful
for storing / retrieving "state" values.)
"""
import string
from Products.CMFCore.PortalFolder import PortalFolder
from Products.CMFDefault.NewsItem import NewsItem
#
# Fake out security (blech!)
#
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
import Acquisition
class FTUser( Acquisition.Implicit ):
def getId( self ):
return 'ft_user'
getUserName = getId
def allowed( self, object, object_roles=None ):
return 1
def fakeSecurity( site ):
newSecurityManager( None, FTUser().__of__( site.acl_users ) )
#
# User management.
#
def _ensureMember( site, member_id, password, roles=('Member',) ):
"""
Ensure that a member with 'member_id' exists.
"""
user = site.acl_users.getUserById( member_id, None )
if user is not None:
return user
site.acl_users._doAddUser( name=member_id
, password=password
, roles=roles
, domains=()
)
user = site.acl_users.getUserById( member_id, None )
user._added_by_FT = 1
site.portal_membership.createMemberarea( member_id )
getattr( site.Members, member_id )._added_by_FT = 1
return user
def _scrubMember( site, member_id, force=0 ):
"""
Blow away 'member_id', IFF created by FT.
"""
user = site.acl_users.getUserById( member_id, None )
if not user:
return
if getattr( user, '_added_by_FT', 0 ) or force:
site.acl_users._doDelUsers( [ member_id ] )
_scrubPath( site, 'Members/%s' % member_id )
#
# Set up default content
#
def _ensurePath( site, path ):
"""
Ensure that 'path' exists within 'site'; return the folder
at the end of 'path'.
"""
if not path:
return site
if type( path ) is type( '' ):
path = string.split( path, '/' )
base = site
for element in path:
if element not in base.objectIds():
folder = PortalFolder( element )
folder._added_by_FT = 1
base._setOb( element, folder )
base = base._getOb( element )
return base
def _scrubPath( site, path ):
"""
Remove any folders added by FT.
"""
if not path:
return
if type( path ) is type( '' ):
path = string.split( path, '/' )
base = site
for element in path:
if element not in base.objectIds():
return
if getattr( element, '_added_by_FT', 0 ):
base._delOb( element )
return
base = base._getOb( element )
def _ensureContent( site, id, type_name, path='' ):
"""
Ensure that a content object exists.
"""
base = _ensurePath( site, path )
if id not in base.objectIds():
fakeSecurity( site )
try:
base.invokeFactory( type_name=type_name, id=id )
item = base._getOb( id )
item._added_by_FT = 1
return item
finally:
noSecurityManager()
def _ensurePublishedDocument( site, id, path=''
, title='', type_name='Document' ):
"""
"""
document = _ensureContent( site, id, type_name, path )
if not getattr( document, '_added_by_FT', 0 ):
return
fakeSecurity( site )
try:
document.edit( text_format='structured-text'
, text='This is some sample content'
)
document.portal_workflow.doActionFor( document
, 'publish'
, comment='FT'
)
finally:
noSecurityManager()
def _ensureTopic( site, id, path='', field='Type', value='News Item' ):
"""
Find / create a topic at path/id; if creating, add an SSC
for 'field'/'value'.
"""
base = _ensurePath( site, path )
if id not in base.objectIds():
fakeSecurity( site )
try:
base.invokeFactory( type_name='Topic', id=id )
item = base._getOb( id )
item._added_by_FT = 1
item.addCriterion( field=field
, criterion_type='String Criterion' )
crit = item.getCriterion( criterion_id=field )
crit.edit( value=value )
return item
finally:
noSecurityManager()
def _scrubContent( site, id, path='' ):
"""
Remove content, if created by FT.
"""
try:
base = _ensurePath( site, path )
item = getattr( base, id, None )
if item and getattr( item, '_added_by_FT', 0 ):
base._delObject( id )
except:
pass
#
# Ensure that correct user exists
#
def _setup_test_user( app, test_vars ):
site_path = test_vars.get( 'site_path', '/' )
userid = test_vars.get( 'userid', 'test_user' )
password = test_vars.get( 'password', 'xyzzy' )
site = app.unrestrictedTraverse( site_path )
_ensureMember( site, userid, password )
def _teardown_test_user( app, test_vars ):
site_path = test_vars.get( 'site_path', '/' )
userid = test_vars.get( 'userid', 'test_user' )
site = app.unrestrictedTraverse( site_path )
_scrubMember( site, userid )
#
# Ensure that 'test_news' (or looked up value) is present, published.
#
def _setup_test_news( app, test_vars ):
site_path = test_vars.get( 'site_path', '/' )
click_through_type = test_vars.get( 'click_through_type', 'News Item' )
click_through_id = test_vars.get( 'click_through_id', 'test_news' )
site = app.unrestrictedTraverse( site_path )
_ensurePublishedDocument( site=site
, id=click_through_id
, type_name=click_through_type
)
def _teardown_test_news( app, test_vars ):
site_path = test_vars.get( 'site_path', '/' )
click_through_id = test_vars.get( 'click_through_id', 'test_news' )
site = app.unrestrictedTraverse( site_path )
_scrubContent( site, click_through_id )
#
# Ensure that 'test_news' (or looked up value) is present, published.
#
def _setup_test_topic( app, test_vars ):
site_path = test_vars.get( 'site_path', '/' )
topic_id = test_vars.get( 'topic_id', 'test_topic' )
topic_crit_field = test_vars.get( 'topic_crit_field', 'Type' )
topic_crit_value = test_vars.get( 'topic_crit_value', 'News Item' )
site = app.unrestrictedTraverse( site_path )
_ensureTopic( site=site
, id=topic_id
, field=topic_crit_field
, value=topic_crit_value
)
def _teardown_test_topic( app, test_vars ):
site_path = test_vars.get( 'site_path', '/' )
topic_id = test_vars.get( 'topic_id', 'test_topic' )
site = app.unrestrictedTraverse( site_path )
_scrubContent( site, topic_id )
#
# advanced_search.zft
#
def advanced_search_setup( app, test_vars, result ):
"""
Ensure that we have at least the one expected piece of content.
"""
_setup_test_news( app, test_vars )
get_transaction().commit()
return 1
def advanced_search_teardown( app, test_vars, result ):
"""
Ensure that we scrub any content we created.
"""
_teardown_test_news( app, test_vars )
get_transaction().commit()
#
# become_member.zft
#
def become_member_setup( app, test_vars, result ):
"""
"""
site_path = test_vars.get( 'site_path', '/' )
userid = test_vars.get( 'userid', 'test_user' )
site = app.unrestrictedTraverse( site_path )
_scrubMember( site, userid, 1 )
get_transaction().commit()
return 1
def become_member_postcondition( app, test_vars, result ):
"""
"""
site_path = test_vars.get( 'site_path', '/' )
userid = test_vars.get( 'userid', 'test_user' )
site = app.unrestrictedTraverse( site_path )
user = site.acl_users.getUserById( userid )
folder = getattr( site.Members, userid )
return ( user.allowed( 'Member' )
and 'Owner' in user.getRolesInContext( folder )
)
def become_member_teardown( app, test_vars, result ):
"""
"""
site_path = test_vars.get( 'site_path', '/' )
userid = test_vars.get( 'userid', 'test_user' )
site = app.unrestrictedTraverse( site_path )
_scrubMember( site, userid )
get_transaction().commit()
#
# browse_news.zft
#
def browse_news_setup( app, test_vars, result ):
"""
Ensure that we have at least the one expected piece of content.
"""
_setup_test_news( app, test_vars )
get_transaction().commit()
return 1
def browse_news_teardown( app, test_vars, result ):
"""
Ensure that we scrub any content we created.
"""
_teardown_test_news( app, test_vars )
get_transaction().commit()
#
# browse_topic.zft
#
def browse_topic_setup( app, test_vars, result ):
# Note that we are *not* (yet) guaranteeing that the
# "click through" page actually shows up on any search
# results page, merely that we can execute these requests.
_setup_test_user( app, test_vars )
_setup_test_news( app, test_vars )
_setup_test_topic( app, test_vars )
get_transaction().commit()
return 1
def browse_topic_teardown( app, test_vars, result ):
_teardown_test_topic( app, test_vars )
_teardown_test_news( app, test_vars )
_teardown_test_user( app, test_vars )
get_transaction().commit()
#
# log_in.zft
#
def log_in_setup( app, test_vars, result ):
"""
"""
_setup_test_user( app, test_vars )
get_transaction().commit()
return 1
def log_in_teardown( app, test_vars, result ):
"""
"""
_teardown_test_user( app, test_vars )
get_transaction().commit()
#
# provide_feeback.zft
#
def provide_feedback_setup( app, test_vars, result ):
"""
"""
site_path = test_vars.get( 'site_path', '/' )
click_through_type = test_vars.get( 'click_through_type', 'News Item' )
site = app.unrestrictedTraverse( site_path )
type_info = getattr( site.portal_types, click_through_type )
result.setStateValue( 'provide_feedback_discussable '
, type_info.allow_discussion )
type_info.allow_discussion = 1
_setup_test_news( app, test_vars )
_setup_test_user( app, test_vars )
get_transaction().commit()
return 1
def provide_feedback_postcondition( app, test_vars, result ):
"""
"""
return 1
def provide_feedback_teardown( app, test_vars, result ):
"""
"""
site_path = test_vars.get( 'site_path', '/' )
click_through_type = test_vars.get( 'click_through_type', 'News Item' )
site = app.unrestrictedTraverse( site_path )
type_info = getattr( site.portal_types, click_through_type )
type_info.allow_discussion = result.getStateValue(
'provide_feedback_discussable ' )
_teardown_test_user( app, test_vars )
_teardown_test_news( app, test_vars )
get_transaction().commit()
#
# quick_search.zft
#
def quick_search_setup( app, test_vars, result ):
# Note that we are *not* (yet) guaranteeing that the
# "click through" page actually shows up on any search
# results page, merely that we can execute these requests.
_setup_test_news( app, test_vars )
_setup_test_user( app, test_vars )
get_transaction().commit()
return 1
def quick_search_teardown( app, test_vars, result ):
_teardown_test_user( app, test_vars )
_teardown_test_news( app, test_vars )
get_transaction().commit()