summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-03-30 01:44:48 -0400
committerChris McDonough <chrism@plope.com>2011-03-30 01:44:48 -0400
commitd0c2f35597d03aebf7226aaa5bd1efc92df199f4 (patch)
treebe337ec6fe59437114030602cf2f93bf8c09ba1b
parent379b47da5f4f820af7d54a6d07553eadbd752f3b (diff)
downloadpyramid-d0c2f35597d03aebf7226aaa5bd1efc92df199f4.tar.gz
pyramid-d0c2f35597d03aebf7226aaa5bd1efc92df199f4.tar.bz2
pyramid-d0c2f35597d03aebf7226aaa5bd1efc92df199f4.zip
condition coverage
-rw-r--r--pyramid/tests/test_session.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/pyramid/tests/test_session.py b/pyramid/tests/test_session.py
index 251d92c23..e8a3318ea 100644
--- a/pyramid/tests/test_session.py
+++ b/pyramid/tests/test_session.py
@@ -63,7 +63,17 @@ class TestUnencryptedCookieSession(unittest.TestCase):
session._cookie_on_exception = False
response = DummyResponse()
self.assertEqual(session._set_cookie(response), False)
-
+
+ def test__set_cookie_on_exception_no_request_exception(self):
+ import webob
+ request = testing.DummyRequest()
+ request.exception = None
+ session = self._makeOne(request)
+ session._cookie_on_exception = False
+ response = webob.Response()
+ self.assertEqual(session._set_cookie(response), True)
+ self.assertEqual(response.headerlist[-1][0], 'Set-Cookie')
+
def test__set_cookie_cookieval_too_long(self):
request = testing.DummyRequest()
session = self._makeOne(request)
@@ -118,7 +128,26 @@ class TestUnencryptedCookieSession(unittest.TestCase):
session.flash('msg1')
session.flash('msg2')
self.assertEqual(session['_f_'], ['msg1', 'msg2'])
-
+
+ def test_flash_allow_duplicate_false(self):
+ request = testing.DummyRequest()
+ session = self._makeOne(request)
+ session.flash('msg1')
+ session.flash('msg1', allow_duplicate=False)
+ self.assertEqual(session['_f_'], ['msg1'])
+
+ def test_flash_allow_duplicate_true_and_msg_not_in_storage(self):
+ request = testing.DummyRequest()
+ session = self._makeOne(request)
+ session.flash('msg1', allow_duplicate=True)
+ self.assertEqual(session['_f_'], ['msg1'])
+
+ def test_flash_allow_duplicate_false_and_msg_not_in_storage(self):
+ request = testing.DummyRequest()
+ session = self._makeOne(request)
+ session.flash('msg1', allow_duplicate=False)
+ self.assertEqual(session['_f_'], ['msg1'])
+
def test_flash_mixed(self):
request = testing.DummyRequest()
session = self._makeOne(request)