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
141
Merge Requests
141
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
af2fd26d
Commit
af2fd26d
authored
Apr 11, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_test_core: pylint
parent
8c41c7c4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
19 additions
and
17 deletions
+19
-17
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testBase.py
.../TestTemplateItem/portal_components/test.erp5.testBase.py
+0
-3
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testCookieCrumbler.py
...ateItem/portal_components/test.erp5.testCookieCrumbler.py
+2
-0
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testERP5Base.py
...tTemplateItem/portal_components/test.erp5.testERP5Base.py
+1
-1
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testERP5Type.py
...tTemplateItem/portal_components/test.erp5.testERP5Type.py
+0
-1
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testIdToolUpgrade.py
...lateItem/portal_components/test.erp5.testIdToolUpgrade.py
+0
-1
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testWorkflowHistoryList.py
...em/portal_components/test.erp5.testWorkflowHistoryList.py
+3
-2
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testXForwardedFor.py
...lateItem/portal_components/test.erp5.testXForwardedFor.py
+8
-6
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testXMLPickle.py
...TemplateItem/portal_components/test.erp5.testXMLPickle.py
+5
-3
No files found.
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testBase.py
View file @
af2fd26d
...
@@ -30,7 +30,6 @@
...
@@ -30,7 +30,6 @@
import
io
import
io
import
unittest
import
unittest
import
os
from
unittest
import
skip
from
unittest
import
skip
from
Testing
import
ZopeTestCase
from
Testing
import
ZopeTestCase
...
@@ -1048,8 +1047,6 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -1048,8 +1047,6 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
self
.
assertEqual
(
None
,
obj
.
getViewPermissionOwner
())
self
.
assertEqual
(
None
,
obj
.
getViewPermissionOwner
())
def
test_Member_Base_download
(
self
):
def
test_Member_Base_download
(
self
):
import
Products.ERP5Type
# tests that members can download files
# tests that members can download files
class
DummyFile
(
io
.
BytesIO
):
class
DummyFile
(
io
.
BytesIO
):
filename
=
'dummy.txt'
filename
=
'dummy.txt'
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testCookieCrumbler.py
View file @
af2fd26d
...
@@ -12,10 +12,12 @@
...
@@ -12,10 +12,12 @@
##############################################################################
##############################################################################
import
six
import
six
# pylint:disable=no-name-in-module
if
six
.
PY2
:
if
six
.
PY2
:
from
base64
import
encodestring
as
base64_encodebytes
from
base64
import
encodestring
as
base64_encodebytes
else
:
else
:
from
base64
import
encodebytes
as
base64_encodebytes
from
base64
import
encodebytes
as
base64_encodebytes
# pylint:enable=no-name-in-module
from
six.moves
import
cStringIO
as
StringIO
from
six.moves
import
cStringIO
as
StringIO
import
unittest
import
unittest
from
six.moves.urllib.parse
import
quote
from
six.moves.urllib.parse
import
quote
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testERP5Base.py
View file @
af2fd26d
...
@@ -36,7 +36,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
...
@@ -36,7 +36,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from
Products.ERP5Type.tests.Sequence
import
SequenceList
from
Products.ERP5Type.tests.Sequence
import
SequenceList
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
,
FileUpload
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
,
FileUpload
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
newSecurityManager
import
six
class
TestERP5Base
(
ERP5TypeTestCase
):
class
TestERP5Base
(
ERP5TypeTestCase
):
"""ERP5 Base tests.
"""ERP5 Base tests.
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testERP5Type.py
View file @
af2fd26d
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
##############################################################################
##############################################################################
import
unittest
import
unittest
import
sys
import
mock
import
mock
import
transaction
import
transaction
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testIdToolUpgrade.py
View file @
af2fd26d
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
#
#
##############################################################################
##############################################################################
import
unittest
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.Globals
import
PersistentMapping
from
Products.ERP5Type.Globals
import
PersistentMapping
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testWorkflowHistoryList.py
View file @
af2fd26d
...
@@ -67,7 +67,7 @@ def old(items):
...
@@ -67,7 +67,7 @@ def old(items):
if
len
(
whl
.
_log
)
<
16
:
if
len
(
whl
.
_log
)
<
16
:
whl
.
_log
.
append
(
item
)
whl
.
_log
.
append
(
item
)
else
:
else
:
prev
=
whl
.
__new__
(
whl
.
__class__
)
prev
=
whl
.
__new__
(
whl
.
__class__
)
# pylint:disable=no-value-for-parameter
prev
.
_prev
=
whl
.
_prev
prev
.
_prev
=
whl
.
_prev
prev
.
_log
=
whl
.
_log
prev
.
_log
=
whl
.
_log
whl
.
_prev
=
prev
whl
.
_prev
=
prev
...
@@ -91,7 +91,8 @@ class TestWorkflowHistoryList(TestCase):
...
@@ -91,7 +91,8 @@ class TestWorkflowHistoryList(TestCase):
self
.
assertEqual
(
ddl
,
new
(
type
(
ddl
),
EXPECTED
))
self
.
assertEqual
(
ddl
,
new
(
type
(
ddl
),
EXPECTED
))
class
check
(
object
):
class
check
(
object
):
def
__getitem__
(
_
,
item
):
# pylint: disable=no-self-argument
def
__getitem__
(
self_
,
item
):
# pylint: disable=no-self-argument
del
self_
try
:
try
:
a
=
EXPECTED
[
item
]
a
=
EXPECTED
[
item
]
except
IndexError
:
except
IndexError
:
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testXForwardedFor.py
View file @
af2fd26d
...
@@ -30,7 +30,7 @@ from Products.ERP5Type.tests.runUnitTest import log_directory
...
@@ -30,7 +30,7 @@ from Products.ERP5Type.tests.runUnitTest import log_directory
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
import
os
import
os
import
requests
import
requests
import
unittest
def
get_Z2_log_last_line
():
def
get_Z2_log_last_line
():
z2_log_path
=
os
.
path
.
join
(
log_directory
,
'Z2.log'
)
z2_log_path
=
os
.
path
.
join
(
log_directory
,
'Z2.log'
)
...
@@ -43,6 +43,7 @@ def get_Z2_log_last_line():
...
@@ -43,6 +43,7 @@ def get_Z2_log_last_line():
f
.
close
()
f
.
close
()
return
last_line
return
last_line
class
TestXForwardedFor
(
ERP5TypeTestCase
):
class
TestXForwardedFor
(
ERP5TypeTestCase
):
def
test_request_with_x_forwarded_for
(
self
):
def
test_request_with_x_forwarded_for
(
self
):
script_container
=
self
.
portal
.
portal_skins
.
custom
script_container
=
self
.
portal
.
portal_skins
.
custom
...
@@ -56,6 +57,7 @@ class TestXForwardedFor(ERP5TypeTestCase):
...
@@ -56,6 +57,7 @@ class TestXForwardedFor(ERP5TypeTestCase):
response
=
requests
.
get
(
response
=
requests
.
get
(
'%s/%s'
%
(
self
.
portal
.
absolute_url
(),
script_id
),
'%s/%s'
%
(
self
.
portal
.
absolute_url
(),
script_id
),
headers
=
{
'X-Forwarded-For'
:
'1.2.3.4'
},
headers
=
{
'X-Forwarded-For'
:
'1.2.3.4'
},
timeout
=
5
,
)
)
self
.
assertNotEqual
(
response
.
text
,
'1.2.3.4'
)
self
.
assertNotEqual
(
response
.
text
,
'1.2.3.4'
)
last_line
=
get_Z2_log_last_line
()
last_line
=
get_Z2_log_last_line
()
...
@@ -63,6 +65,7 @@ class TestXForwardedFor(ERP5TypeTestCase):
...
@@ -63,6 +65,7 @@ class TestXForwardedFor(ERP5TypeTestCase):
response
=
requests
.
get
(
response
=
requests
.
get
(
'%s/%s'
%
(
self
.
portal
.
absolute_url
(),
script_id
),
'%s/%s'
%
(
self
.
portal
.
absolute_url
(),
script_id
),
headers
=
{
'X-Forwarded-For'
:
'1.2.3.4, 5.6.7.8'
},
headers
=
{
'X-Forwarded-For'
:
'1.2.3.4, 5.6.7.8'
},
timeout
=
5
,
)
)
self
.
assertNotEqual
(
response
.
text
,
'1.2.3.4'
)
self
.
assertNotEqual
(
response
.
text
,
'1.2.3.4'
)
self
.
assertNotEqual
(
response
.
text
,
'5.6.7.8'
)
self
.
assertNotEqual
(
response
.
text
,
'5.6.7.8'
)
...
@@ -71,6 +74,7 @@ class TestXForwardedFor(ERP5TypeTestCase):
...
@@ -71,6 +74,7 @@ class TestXForwardedFor(ERP5TypeTestCase):
self
.
assertFalse
(
last_line
.
startswith
(
'5.6.7.8 - '
),
last_line
)
self
.
assertFalse
(
last_line
.
startswith
(
'5.6.7.8 - '
),
last_line
)
response
=
requests
.
get
(
response
=
requests
.
get
(
'%s/%s'
%
(
self
.
portal
.
absolute_url
(),
script_id
),
'%s/%s'
%
(
self
.
portal
.
absolute_url
(),
script_id
),
timeout
=
5
,
)
)
self
.
assertNotEqual
(
response
.
text
,
'1.2.3.4'
)
self
.
assertNotEqual
(
response
.
text
,
'1.2.3.4'
)
last_line
=
get_Z2_log_last_line
()
last_line
=
get_Z2_log_last_line
()
...
@@ -81,6 +85,7 @@ class TestXForwardedFor(ERP5TypeTestCase):
...
@@ -81,6 +85,7 @@ class TestXForwardedFor(ERP5TypeTestCase):
response
=
requests
.
get
(
response
=
requests
.
get
(
'%s/%s'
%
(
self
.
portal
.
absolute_url
(),
script_id
),
'%s/%s'
%
(
self
.
portal
.
absolute_url
(),
script_id
),
headers
=
{
'X-Forwarded-For'
:
'1.2.3.4'
},
headers
=
{
'X-Forwarded-For'
:
'1.2.3.4'
},
timeout
=
5
,
)
)
self
.
assertEqual
(
response
.
text
,
'1.2.3.4'
)
self
.
assertEqual
(
response
.
text
,
'1.2.3.4'
)
last_line
=
get_Z2_log_last_line
()
last_line
=
get_Z2_log_last_line
()
...
@@ -88,18 +93,15 @@ class TestXForwardedFor(ERP5TypeTestCase):
...
@@ -88,18 +93,15 @@ class TestXForwardedFor(ERP5TypeTestCase):
response
=
requests
.
get
(
response
=
requests
.
get
(
'%s/%s'
%
(
self
.
portal
.
absolute_url
(),
script_id
),
'%s/%s'
%
(
self
.
portal
.
absolute_url
(),
script_id
),
headers
=
{
'X-Forwarded-For'
:
'1.2.3.4, 5.6.7.8'
},
headers
=
{
'X-Forwarded-For'
:
'1.2.3.4, 5.6.7.8'
},
timeout
=
5
,
)
)
self
.
assertEqual
(
response
.
text
,
'1.2.3.4'
)
self
.
assertEqual
(
response
.
text
,
'1.2.3.4'
)
last_line
=
get_Z2_log_last_line
()
last_line
=
get_Z2_log_last_line
()
self
.
assertTrue
(
last_line
.
startswith
(
'1.2.3.4 - '
),
last_line
)
self
.
assertTrue
(
last_line
.
startswith
(
'1.2.3.4 - '
),
last_line
)
response
=
requests
.
get
(
response
=
requests
.
get
(
'%s/%s'
%
(
self
.
portal
.
absolute_url
(),
script_id
),
'%s/%s'
%
(
self
.
portal
.
absolute_url
(),
script_id
),
timeout
=
5
,
)
)
self
.
assertNotEqual
(
response
.
text
,
'1.2.3.4'
)
self
.
assertNotEqual
(
response
.
text
,
'1.2.3.4'
)
last_line
=
get_Z2_log_last_line
()
last_line
=
get_Z2_log_last_line
()
self
.
assertFalse
(
last_line
.
startswith
(
'1.2.3.4 - '
),
last_line
)
self
.
assertFalse
(
last_line
.
startswith
(
'1.2.3.4 - '
),
last_line
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestXForwardedFor
))
return
suite
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testXMLPickle.py
View file @
af2fd26d
...
@@ -60,10 +60,10 @@ class XMLPickleTestCase(unittest.TestCase):
...
@@ -60,10 +60,10 @@ class XMLPickleTestCase(unittest.TestCase):
class
DummyJar
:
class
DummyJar
:
loaded
=
None
loaded
=
None
"""follow interface expected by importXML"""
"""follow interface expected by importXML"""
def
importFile
(
self
,
file
,
clue
):
def
importFile
(
self
,
file
_
,
clue
):
assertEqual
(
clue
,
'ignored'
)
assertEqual
(
clue
,
'ignored'
)
assertEqual
(
file
.
read
(
4
),
b'ZEXP'
)
assertEqual
(
file
_
.
read
(
4
),
b'ZEXP'
)
unpickler
=
pickle
.
Unpickler
(
file
)
unpickler
=
pickle
.
Unpickler
(
file
_
)
if
persistent_load
:
if
persistent_load
:
unpickler
.
persistent_load
=
persistent_load
unpickler
.
persistent_load
=
persistent_load
self
.
loaded
=
unpickler
.
load
()
self
.
loaded
=
unpickler
.
load
()
...
@@ -126,6 +126,7 @@ class TestXMLPickle(XMLPickleTestCase):
...
@@ -126,6 +126,7 @@ class TestXMLPickle(XMLPickleTestCase):
if
six
.
PY2
:
if
six
.
PY2
:
def
test_long
(
self
):
def
test_long
(
self
):
# pylint:disable=undefined-variable
self
.
check_and_load
(
long
(
-
0
))
self
.
check_and_load
(
long
(
-
0
))
self
.
check_and_load
(
long
(
1
))
self
.
check_and_load
(
long
(
1
))
self
.
check_and_load
(
long
(
-
1
))
self
.
check_and_load
(
long
(
-
1
))
...
@@ -134,6 +135,7 @@ class TestXMLPickle(XMLPickleTestCase):
...
@@ -134,6 +135,7 @@ class TestXMLPickle(XMLPickleTestCase):
self
.
check_and_load
(
long
(
0xffff
))
self
.
check_and_load
(
long
(
0xffff
))
self
.
check_and_load
(
long
(
2
**
128
))
self
.
check_and_load
(
long
(
2
**
128
))
self
.
check_and_load
(
12345678910111213141516178920
<<
(
256
*
8
))
self
.
check_and_load
(
12345678910111213141516178920
<<
(
256
*
8
))
# pylint:enable=undefined-variable
def
test_float
(
self
):
def
test_float
(
self
):
self
.
check_and_load
(
-
0.0
)
self
.
check_and_load
(
-
0.0
)
...
...
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