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
Labels
Merge Requests
138
Merge Requests
138
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
cbd9c351
Commit
cbd9c351
authored
Apr 21, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_core_test: pylint for py3
parent
81e2f344
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
77 deletions
+79
-77
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testAlarm.py
...TestTemplateItem/portal_components/test.erp5.testAlarm.py
+1
-1
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testERP5Catalog.py
...mplateItem/portal_components/test.erp5.testERP5Catalog.py
+4
-3
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testERP5Core.py
...tTemplateItem/portal_components/test.erp5.testERP5Core.py
+74
-73
No files found.
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testAlarm.py
View file @
cbd9c351
...
...
@@ -113,7 +113,7 @@ class TestAlarm(AlarmTestCase):
finally
:
self
.
portal
.
portal_activities
.
manageClearActivities
(
keep
=
0
)
else
:
raise
Exception
(
'Tic did not raise though activity was supposed to fail'
)
self
.
fail
(
'Tic did not raise though activity was supposed to fail'
)
# Make the sense method succeed and leave a trace
self
.
getPortal
().
portal_skins
[
skin_folder_id
][
sense_method_id
].
ZPythonScript_edit
(
'*args,**kw'
,
'context.newActiveProcess()'
)
alarm
.
activeSense
()
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testERP5Catalog.py
View file @
cbd9c351
...
...
@@ -642,7 +642,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
self
.
assertEqual
([
'5'
],
folder_object_list
)
if
six
.
PY2
:
folder_object_list
=
[
x
.
getObject
().
getId
()
for
x
in
person_module
.
searchFolder
(
title
=
unicod
e
(
title
,
'utf-8'
))]
person_module
.
searchFolder
(
title
=
six
.
text_typ
e
(
title
,
'utf-8'
))]
self
.
assertEqual
([
'5'
],
folder_object_list
)
def
test_Collation
(
self
):
...
...
@@ -2167,7 +2167,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
result
=
query
(
'SELECT * FROM roles_and_users WHERE allowedRolesAndUsers LIKE "%s:%%" AND uid = %i'
%
(
line
[
'allowedRolesAndUsers'
],
uid
)
)
self
.
assertNotEqual
(
len
(
result
),
0
,
'No line found for allowedRolesAndUsers=%r and uid=%i'
%
(
line
[
'allowedRolesAndUsers'
],
uid
))
else
:
raise
Exception
(
'Malformed allowedRolesAndUsers value: %(allowedRolesAndUsers)r'
%
line
)
raise
ValueError
(
'Malformed allowedRolesAndUsers value: %(allowedRolesAndUsers)r'
%
line
)
# Check that object that 'bar' can view because of 'Author' role can *not*
# be found when searching for his other 'Whatever' role.
...
...
@@ -4067,7 +4067,8 @@ VALUES
def
doSomething
(
self
,
message_list
):
r
=
[]
for
m
in
message_list
:
m
.
result
=
r
.
append
(
m
.
object
.
getPath
())
r
.
append
(
m
.
object
.
getPath
())
m
.
result
=
None
r
.
sort
()
group_method_call_list
.
append
(
r
)
self
.
portal
.
portal_activities
.
__class__
.
doSomething
=
doSomething
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testERP5Core.py
View file @
cbd9c351
...
...
@@ -42,59 +42,59 @@ from Products.ERP5Type.tests.utils import DummyTranslationService
from
zExceptions
import
Unauthorized
if
1
:
# BBB
# Zope 2.12, simulate setting the globalTranslationService with
# zope.i18n utilities
import
zope.interface
import
zope.component
import
Acquisition
global_translation_service
=
None
from
zope.i18n.interfaces
import
ITranslationDomain
,
\
IFallbackTranslationDomainFactory
@
zope
.
interface
.
implementer
(
ITranslationDomain
)
@
zope
.
interface
.
provider
(
IFallbackTranslationDomainFactory
)
class
DummyTranslationDomainFallback
(
object
):
def
__init__
(
self
,
domain
):
self
.
domain
=
domain
def
translate
(
self
,
msgid
,
mapping
=
None
,
*
args
,
**
kw
):
return
global_translation_service
.
translate
(
self
.
domain
,
msgid
,
mapping
,
*
args
,
**
kw
)
def
setGlobalTranslationService
(
translation_service
):
global
global_translation_service
# pylint:disable=global-statement
global_translation_service
=
translation_service
zope
.
component
.
provideUtility
(
DummyTranslationDomainFallback
,
provides
=
IFallbackTranslationDomainFactory
)
# disable translation for the 'ui' domain so it can use the fallback above.
# Save it on a portal attribute since we don't have access to the test
# class
sm
=
zope
.
component
.
getSiteManager
(
)
portal
=
Acquisition
.
aq_parent
(
sm
)
from
zope.interface.interfaces
import
ComponentLookupError
try
:
ui_domain
=
sm
.
getUtility
(
ITranslationDomain
,
name
=
'ui'
)
except
ComponentLookupError
:
pass
else
:
# store in a list to avoid acquisition wrapping
portal
.
_save_ui_domain
=
[
ui_domain
]
sm
.
unregisterUtility
(
provided
=
ITranslationDomain
,
name
=
'ui'
)
def
unregister_translation_domain_fallback
():
from
zope.component.globalregistry
import
base
base
.
unregisterUtility
(
DummyTranslationDomainFallback
)
sm
=
zope
.
component
.
getSiteManager
(
)
portal
=
Acquisition
.
aq_parent
(
sm
)
ui_domain
=
getattr
(
portal
,
'_save_ui_domain'
,
[
None
]).
pop
()
if
ui_domain
is
not
None
:
# aq_base() to remove acquisition wrapping
ui_domain
=
Acquisition
.
aq_base
(
ui_domain
)
sm
.
registerUtility
(
ui_domain
,
ITranslationDomain
,
'ui'
)
del
portal
.
_save_ui_domain
# Zope 2.12, simulate setting the globalTranslationService with
# zope.i18n utilities
import
zope.interface
import
zope.component
import
Acquisition
global_translation_service
=
None
from
zope.i18n.interfaces
import
ITranslationDomain
,
\
IFallbackTranslationDomainFactory
@
zope
.
interface
.
implementer
(
ITranslationDomain
)
@
zope
.
interface
.
provider
(
IFallbackTranslationDomainFactory
)
class
DummyTranslationDomainFallback
(
object
):
def
__init__
(
self
,
domain
):
self
.
domain
=
domain
def
translate
(
self
,
msgid
,
mapping
=
None
,
*
args
,
**
kw
):
return
global_translation_service
.
translate
(
self
.
domain
,
msgid
,
mapping
,
*
args
,
**
kw
)
def
setGlobalTranslationService
(
translation_service
):
global
global_translation_service
# pylint:disable=global-statement
global_translation_service
=
translation_service
zope
.
component
.
provideUtility
(
DummyTranslationDomainFallback
,
provides
=
IFallbackTranslationDomainFactory
)
# disable translation for the 'ui' domain so it can use the fallback above.
# Save it on a portal attribute since we don't have access to the test
# class
sm
=
zope
.
component
.
getSiteManager
()
portal
=
Acquisition
.
aq_parent
(
sm
)
from
zope.interface.interfaces
import
ComponentLookupError
try
:
ui_domain
=
sm
.
getUtility
(
ITranslationDomain
,
name
=
'ui'
)
except
ComponentLookupError
:
pass
else
:
# store in a list to avoid acquisition wrapping
portal
.
_save_ui_domain
=
[
ui_domain
]
sm
.
unregisterUtility
(
provided
=
ITranslationDomain
,
name
=
'ui'
)
def
unregister_translation_domain_fallback
():
from
zope.component.globalregistry
import
base
base
.
unregisterUtility
(
DummyTranslationDomainFallback
)
sm
=
zope
.
component
.
getSiteManager
(
)
portal
=
Acquisition
.
aq_parent
(
sm
)
ui_domain
=
getattr
(
portal
,
'_save_ui_domain'
,
[
None
]).
pop
(
)
if
ui_domain
is
not
None
:
# aq_base() to remove acquisition wrapping
ui_domain
=
Acquisition
.
aq_base
(
ui_domain
)
sm
.
registerUtility
(
ui_domain
,
ITranslationDomain
,
'ui'
)
del
portal
.
_save_ui_domain
HTTP_OK
=
200
HTTP_UNAUTHORIZED
=
401
...
...
@@ -599,26 +599,27 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
# now let's simulate a site just migrated from Zope 2.8 that's being
# accessed for the first time:
from
Products.ERP5
import
ERP5Site
if
1
:
# BBB
setSite
()
# Sites from Zope2.8 don't have a site_manager yet.
del
self
.
portal
.
_components
self
.
assertIsNotNone
(
ERP5Site
.
_missing_tools_registered
)
ERP5Site
.
_missing_tools_registered
=
None
self
.
commit
()
# check that we can't get any translation utility
self
.
assertEqual
(
queryUtility
(
ITranslationDomain
,
'erp5_ui'
),
None
)
# Now simulate first access. Default behaviour from
# ObjectManager is to raise a ComponentLookupError here:
setSite
(
self
.
portal
)
self
.
commit
()
self
.
assertIsNotNone
(
ERP5Site
.
_missing_tools_registered
)
# This should have automatically reconstructed the i18n utility
# registrations:
self
.
assertEqual
(
queryUtility
(
ITranslationDomain
,
'erp5_ui'
),
erp5_ui_catalog
)
self
.
assertEqual
(
queryUtility
(
ITranslationDomain
,
'ui'
),
erp5_ui_catalog
)
# BBB
setSite
()
# Sites from Zope2.8 don't have a site_manager yet.
del
self
.
portal
.
_components
self
.
assertIsNotNone
(
ERP5Site
.
_missing_tools_registered
)
ERP5Site
.
_missing_tools_registered
=
None
self
.
commit
()
# check that we can't get any translation utility
self
.
assertEqual
(
queryUtility
(
ITranslationDomain
,
'erp5_ui'
),
None
)
# Now simulate first access. Default behaviour from
# ObjectManager is to raise a ComponentLookupError here:
setSite
(
self
.
portal
)
self
.
commit
()
self
.
assertIsNotNone
(
ERP5Site
.
_missing_tools_registered
)
# This should have automatically reconstructed the i18n utility
# registrations:
self
.
assertEqual
(
queryUtility
(
ITranslationDomain
,
'erp5_ui'
),
erp5_ui_catalog
)
self
.
assertEqual
(
queryUtility
(
ITranslationDomain
,
'ui'
),
erp5_ui_catalog
)
def
test_BasicAuthenticateDesactivated
(
self
):
"""Make sure Unauthorized error does not lead to Basic auth popup in browser"""
...
...
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