Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Vincent Bechu
erp5
Commits
cd06a067
Commit
cd06a067
authored
Aug 30, 2011
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test External Account creation.
parent
6f94cb80
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
139 additions
and
0 deletions
+139
-0
product/ERP5/tests/testExternalAccount.py
product/ERP5/tests/testExternalAccount.py
+139
-0
No files found.
product/ERP5/tests/testExternalAccount.py
0 → 100644
View file @
cd06a067
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004, 2005, 2006 Nexedi SARL and Contributors.
# All Rights Reserved.
# Ivan Tyagov <ivan@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import
unittest
import
time
import
transaction
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.backportUnittest
import
expectedFailure
from
Products.Formulator.Errors
import
ValidationError
from
Products.ERP5Type.Document
import
newTempBase
from
DateTime
import
DateTime
class
TestExternalAccount
(
ERP5TypeTestCase
):
"""
Test for erp5_authentication_policy business template.
"""
manager_username
=
'zope'
manager_password
=
'zope'
credential
=
'%s:%s'
%
(
manager_username
,
manager_password
)
def
getTitle
(
self
):
return
"TestExternalAccount"
def
getBusinessTemplateList
(
self
):
"""
Return the list of required business templates.
"""
return
(
'erp5_core_proxy_field_legacy'
,
'erp5_base'
,
'erp5_external_account'
,)
def
afterSetUp
(
self
):
portal
=
self
.
getPortal
()
uf
=
portal
.
acl_users
uf
.
_doAddUser
(
self
.
manager_username
,
self
.
manager_password
,
[
'Manager'
],
[])
self
.
login
(
self
.
manager_username
)
# Setup auth policy
preference
=
portal
.
portal_preferences
.
newContent
(
portal_type
=
'System Preference'
,
title
=
'External Account'
,
preferred_managed_external_domain_name_list
=
[
'erp5.org'
])
preference
.
enable
()
self
.
stepTic
()
def
test_01_PersonExternalEmailAccountCreation
(
self
):
"""
Test that external account creation.
"""
portal
=
self
.
getPortal
()
person
=
portal
.
person_module
.
newContent
(
first_name
=
'First'
,
last_name
=
'Last'
,
default_email_text
=
'ivan@erp5.org'
)
person
.
validate
()
career
=
person
.
newContent
(
portal_type
=
'Career'
,
title
=
'Career 0'
)
career
.
start
()
self
.
stepTic
()
self
.
assertEqual
(
1
,
len
(
portal
.
external_account_module
.
objectValues
()))
self
.
assertEqual
(
person
,
portal
.
external_account_module
.
objectValues
()[
0
].
getSourceValue
())
self
.
assertEqual
(
person
.
Person_getDefaultExternalEmailText
(),
\
portal
.
external_account_module
.
objectValues
()[
0
].
getUrlString
())
self
.
assertEqual
(
'validated'
,
\
portal
.
external_account_module
.
objectValues
()[
0
].
getValidationState
())
# invalidate career should invalidate account
career
.
stop
()
self
.
stepTic
()
self
.
assertEqual
(
1
,
len
(
portal
.
external_account_module
.
objectValues
()))
self
.
assertEqual
(
person
,
portal
.
external_account_module
.
objectValues
()[
0
].
getSourceValue
())
self
.
assertEqual
(
person
.
Person_getDefaultExternalEmailText
(),
\
portal
.
external_account_module
.
objectValues
()[
0
].
getUrlString
())
self
.
assertEqual
(
'invalidated'
,
\
portal
.
external_account_module
.
objectValues
()[
0
].
getValidationState
())
# add a new 1 + careers then only one email account should exist
career
=
person
.
newContent
(
portal_type
=
'Career'
,
title
=
'Career 1'
)
career
.
start
()
self
.
stepTic
()
career
=
person
.
newContent
(
portal_type
=
'Career'
,
title
=
'Career 2'
)
career
.
start
()
self
.
stepTic
()
self
.
assertEqual
(
1
,
len
(
portal
.
external_account_module
.
objectValues
()))
self
.
assertEqual
(
person
,
portal
.
external_account_module
.
objectValues
()[
0
].
getSourceValue
())
self
.
assertEqual
(
person
.
Person_getDefaultExternalEmailText
(),
\
portal
.
external_account_module
.
objectValues
()[
0
].
getUrlString
())
self
.
assertEqual
(
'validated'
,
\
portal
.
external_account_module
.
objectValues
()[
0
].
getValidationState
())
# create a person whose email is NOT managed
portal
=
self
.
getPortal
()
person
=
portal
.
person_module
.
newContent
(
first_name
=
'First'
,
last_name
=
'Last'
,
default_email_text
=
'ivan@not-managed-domain.org'
)
person
.
validate
()
career
=
person
.
newContent
(
portal_type
=
'Career'
,
title
=
'Career 0'
)
career
.
start
()
self
.
stepTic
()
self
.
assertEqual
(
1
,
len
(
portal
.
external_account_module
.
objectValues
()))
self
.
assertFalse
(
person
in
[
x
.
getSourceValue
()
for
x
in
portal
.
external_account_module
.
objectValues
()])
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestExternalAccount
))
return
suite
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment