You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2014/02/27 17:18:21 UTC
[04/16] git commit: [#7210] Fixed and added test for
substitute_extensions not flushing after error
[#7210] Fixed and added test for substitute_extensions not flushing after error
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/045cf231
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/045cf231
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/045cf231
Branch: refs/heads/cj/7210
Commit: 045cf2313fa61ba8cc72c8a00627a3476b1bc565
Parents: 7ba3fb7
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue Feb 25 23:11:44 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Tue Feb 25 23:14:54 2014 +0000
----------------------------------------------------------------------
Allura/allura/tests/unit/test_session.py | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/045cf231/Allura/allura/tests/unit/test_session.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_session.py b/Allura/allura/tests/unit/test_session.py
index a5fb080..89aa8b8 100644
--- a/Allura/allura/tests/unit/test_session.py
+++ b/Allura/allura/tests/unit/test_session.py
@@ -27,6 +27,19 @@ from allura.model.session import BatchIndexer, substitute_extensions
def test_extensions_cm():
session = mock.Mock(_kwargs=dict(extensions=[]))
extension = mock.Mock()
+ with substitute_extensions(session, [extension]) as sess:
+ assert session.flush.call_count == 1
+ assert session.close.call_count == 1
+ assert sess == session
+ assert sess._kwargs['extensions'] == [extension]
+ assert session.flush.call_count == 2
+ assert session.close.call_count == 2
+ assert session._kwargs['extensions'] == []
+
+
+def test_extensions_cm_raises():
+ session = mock.Mock(_kwargs=dict(extensions=[]))
+ extension = mock.Mock()
with td.raises(ValueError):
with substitute_extensions(session, [extension]) as sess:
assert session.flush.call_count == 1
@@ -34,8 +47,8 @@ def test_extensions_cm():
assert sess == session
assert sess._kwargs['extensions'] == [extension]
raise ValueError('test')
- assert session.flush.call_count == 2
- assert session.close.call_count == 2
+ assert session.flush.call_count == 1
+ assert session.close.call_count == 1
assert session._kwargs['extensions'] == []