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
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
96ec3231
Commit
96ec3231
authored
Nov 01, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SessionTool: fix DistributedSession conformance to dict interface
.pop .popitem and .setdefault where returning None
parent
1b94a641
Pipeline
#5595
failed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
4 deletions
+28
-4
product/ERP5Type/Tool/SessionTool.py
product/ERP5Type/Tool/SessionTool.py
+7
-4
product/ERP5Type/tests/testSessionTool.py
product/ERP5Type/tests/testSessionTool.py
+21
-0
No files found.
product/ERP5Type/Tool/SessionTool.py
View file @
96ec3231
...
...
@@ -135,16 +135,19 @@ class DistributedSession(Session):
self
.
_updateStorage
()
def
setdefault
(
self
,
key
,
failobj
=
None
):
Session
.
setdefault
(
self
,
key
,
failobj
)
r
=
Session
.
setdefault
(
self
,
key
,
failobj
)
self
.
_updateStorage
()
return
r
def
pop
(
self
,
key
,
*
args
):
Session
.
pop
(
self
,
key
,
*
args
)
def
pop
(
self
,
key
,
*
args
):
r
=
Session
.
pop
(
self
,
key
,
*
args
)
self
.
_updateStorage
()
return
r
def
popitem
(
self
):
Session
.
popitem
(
self
)
r
=
Session
.
popitem
(
self
)
self
.
_updateStorage
()
return
r
class
SessionTool
(
BaseTool
):
...
...
product/ERP5Type/tests/testSessionTool.py
View file @
96ec3231
...
...
@@ -183,6 +183,7 @@ class TestSessionTool(ERP5TypeTestCase):
sequence_list
=
None
,
**
kw
):
session
=
self
.
portal
.
portal_sessions
[
self
.
session_id
]
session
.
clear
()
# get / set
session
[
'foo'
]
=
'Bar'
self
.
assertTrue
(
'foo'
in
session
)
self
.
assertEqual
(
'Bar'
,
session
[
'foo'
])
...
...
@@ -191,6 +192,26 @@ class TestSessionTool(ERP5TypeTestCase):
self
.
assertEqual
(
'Default'
,
session
.
get
(
'bar'
,
'Default'
))
self
.
assertRaises
(
KeyError
,
session
.
__getitem__
,
'bar'
)
# pop
session
[
'pop'
]
=
'Bar'
self
.
assertEqual
(
'Bar'
,
session
.
pop
(
'pop'
))
self
.
assertRaises
(
KeyError
,
session
.
__getitem__
,
'pop'
)
self
.
assertEqual
(
'Default'
,
session
.
pop
(
'pop'
,
'Default'
))
# setdefault
self
.
assertEqual
(
'Default'
,
session
.
setdefault
(
'setdefault'
,
'Default'
))
self
.
assertEqual
(
'Default'
,
session
.
setdefault
(
'setdefault'
,
'Default was set'
))
# clear / items
session
.
clear
()
self
.
assertEqual
([],
list
(
session
.
items
()))
# popitem
session
[
'popitem'
]
=
'Bar'
self
.
assertEqual
((
'popitem'
,
'Bar'
),
session
.
popitem
())
self
.
assertRaises
(
KeyError
,
session
.
popitem
)
def
stepTestSessionGetattr
(
self
,
sequence
=
None
,
\
sequence_list
=
None
,
**
kw
):
session
=
self
.
portal
.
portal_sessions
[
self
.
session_id
]
...
...
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