Code

- put all methods for parsing a message into a list and call all in a
[roundup.git] / test / test_hyperdbvals.py
index b99f982103a8fde16e9b799fceb751e75d370624..9b644421605a36f7a5afc70ad49c9c4e5da46c56 100644 (file)
@@ -8,9 +8,10 @@
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 #
-# $Id: test_hyperdbvals.py,v 1.1 2003-11-11 00:35:14 richard Exp $
+# $Id: test_hyperdbvals.py,v 1.3 2006-08-18 01:26:19 richard Exp $
 
-import unittest, os, shutil, errno, sys, difflib, cgi, re, sha
+import unittest, os, shutil, errno, sys, difflib, cgi, re
+from roundup.anypy.hashlib_ import sha1
 
 from roundup import init, instance, password, hyperdb, date
 
@@ -59,16 +60,20 @@ class RawToHyperdbTest(unittest.TestCase):
         return hyperdb.rawToHyperdb(TestDatabase(), TestClass(), itemid,
             propname, value)
     def testString(self):
+        self.assertEqual(self._test('password', ''), None)
         self.assertEqual(self._test('string', '  a string '), 'a string')
     def testNumber(self):
+        self.assertEqual(self._test('password', ''), None)
         self.assertEqual(self._test('number', '  10 '), 10)
         self.assertEqual(self._test('number', '  1.5 '), 1.5)
     def testBoolean(self):
+        self.assertEqual(self._test('password', ''), None)
         for true in 'yes true on 1'.split():
             self.assertEqual(self._test('boolean', '  %s '%true), 1)
         for false in 'no false off 0'.split():
             self.assertEqual(self._test('boolean', '  %s '%false), 0)
     def testPassword(self):
+        self.assertEqual(self._test('password', ''), None)
         self.assertEqual(self._test('password', '  a string '), 'a string')
         val = self._test('password', '  a string ')
         self.assert_(isinstance(val, password.Password))
@@ -76,13 +81,14 @@ class RawToHyperdbTest(unittest.TestCase):
         self.assert_(isinstance(val, password.Password))
         val = self._test('password', '{crypt}a string')
         self.assert_(isinstance(val, password.Password))
-        s = sha.sha('a string').hexdigest()
+        s = sha1('a string').hexdigest()
         val = self._test('password', '{SHA}'+s)
         self.assert_(isinstance(val, password.Password))
         self.assertEqual(val, 'a string')
         self.assertRaises(hyperdb.HyperdbValueError, self._test,
             'password', '{fubar}a string')
     def testDate(self):
+        self.assertEqual(self._test('password', ''), None)
         val = self._test('date', ' 2003-01-01  ')
         self.assert_(isinstance(val, date.Date))
         val = self._test('date', ' 2003/01/01  ')
@@ -94,11 +100,13 @@ class RawToHyperdbTest(unittest.TestCase):
         self.assertRaises(hyperdb.HyperdbValueError, self._test, 'date',
             'fubar')
     def testInterval(self):
+        self.assertEqual(self._test('password', ''), None)
         val = self._test('interval', ' +1d  ')
         self.assert_(isinstance(val, date.Interval))
         self.assertRaises(hyperdb.HyperdbValueError, self._test, 'interval',
             'fubar')
     def testLink(self):
+        self.assertEqual(self._test('password', ''), None)
         self.assertEqual(self._test('link', '1'), '1')
         self.assertEqual(self._test('link', 'valid'), '1')
         self.assertRaises(hyperdb.HyperdbValueError, self._test, 'link',