changeset 592:60e6936eaf4c pytest2

added tests to testvalidpassword and testvalidtoken in test_crypto,py
author pkumar <contactprashantat@gmail.com>
date Mon, 27 Jun 2011 00:24:26 +0530
parents bbd6da3dc2f2
children b3aeaf60adcc
files MoinMoin/util/_tests/test_crypto.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/util/_tests/test_crypto.py	Sat Jun 25 10:58:17 2011 +0530
+++ b/MoinMoin/util/_tests/test_crypto.py	Mon Jun 27 00:24:26 2011 +0530
@@ -58,13 +58,20 @@
         hash_val = crypto.crypt_password(u"MoinMoin", salt='12345')
         result = crypto.valid_password(u'MoinMoin', hash_val)
         assert result
+        with pytest.raises(ValueError):
+            invlid_result = crypto.valid_password("MoinMoin", '{junk_value}')
+            
 
 class TestToken(object):
     """ tests for the generated tokens """
 
     def testvalidtoken(self):
         """ validate the token """
-        test_key, test_token = crypto.generate_token(key='MoinMoin')
+        test_key, test_token = crypto.generate_token(key='MoinMoin') # having some key value
+        result = crypto.valid_token(test_key, test_token)
+        assert result
+        
+        test_key, test_token = crypto.generate_token() # key value is none
         result = crypto.valid_token(test_key, test_token)
         assert result