incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject git commit: [#7210] Fixed and added test for substitute_extensions not flushing after error
Date Tue, 25 Feb 2014 23:16:13 GMT
Repository: incubator-allura
Updated Branches:
  refs/heads/master 7ba3fb794 -> 045cf2313


[#7210] Fixed and added test for substitute_extensions not flushing after error

Signed-off-by: Cory Johns <cjohns@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/master
Commit: 045cf2313fa61ba8cc72c8a00627a3476b1bc565
Parents: 7ba3fb7
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Tue Feb 25 23:11:44 2014 +0000
Committer: Cory Johns <cjohns@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'] == []
 
 


Mime
View raw message