Commits

Kelvin Wong committed cc2db06 Draft

Added tests for the new helper functions. Rename other test class to better match pkg

Comments (0)

Files changed (1)

tests/test_django_scrypt.py

 from django.utils.translation import ugettext_noop as _
 
 import django_scrypt
-from django_scrypt.hashers import ScryptPasswordHasher
+from django_scrypt.hashers import ScryptPasswordHasher, base64, stripws
 import sys
 
 try:
         self.assertTrue(isinstance(unicode_str, str))
 
 
+class TestHelpers(TestCase):
+    def setUp(self):
+        self.utf8_encoded = b'a\xc2\xac\xe1\x88\xb4\xe2\x82\xac\xe8\x80\x80'
+        self.test_str = b'Test'
+        self.test_str_base64 = b'VGVzdA==\n'
+        self.spacey_str = ' Test \ntest \n'
+        self.stripped_str = 'Test \ntest'
+
+    def test_base64(self):
+        """Returns a Base64 encoded string"""
+        encoded = base64(self.test_str)
+        expected = self.test_str_base64
+        self.assertEqual(encoded, expected)
+
+    def test_stripws(self):
+        """Return a copy of the string with leading and trailing characters
+        removed
+        """
+        stripped = stripws(self.spacey_str)
+        expected = self.stripped_str
+        self.assertEqual(stripped, expected)
+
 @skipUnless(scrypt, "Uninstalled scrypt module needed to generate hash")
-class TestScrypt(TestCase):
+class TestDjangoScrypt(TestCase):
 
     def setUp(self):
         scrypt_hashers = (