Permalink
Browse files

Added tests for coerce_timedelta.

  • Loading branch information...
1 parent 8299468 commit 89b99ed6f2eef26962ef9da02ce210b2bc8f2f62 @mmerickel mmerickel committed Mar 12, 2012
Showing with 19 additions and 0 deletions.
  1. +3 −0 README.rst
  2. +16 −0 anykeystore/tests/test_utils.py
View
@@ -14,8 +14,11 @@ Usage
store = create_store(
'sqla', url='postgres+psycopg2://bob@localhost/mydb')
+.. code-block:: python
+
settings = {
'mystore.store': 'sqla',
'mystore.url': 'mysql://bob@localhost/mydb',
}
+
store = create_store_from_settings(settings, prefix='mystore.')
@@ -0,0 +1,16 @@
+import unittest
+from datetime import timedelta
+
+class TestCoerceTimedelta(unittest.TestCase):
+ def _callFUT(self, value):
+ from anykeystore.utils import coerce_timedelta
+ return coerce_timedelta(value)
+
+ def test_coerce_with_int(self):
+ result = self._callFUT(20)
+ self.assertEqual(result, timedelta(seconds=20))
+
+ def test_coerce_with_timedelta(self):
+ dt = timedelta(seconds=1)
+ result = self._callFUT(dt)
+ self.assertEqual(result, dt)

0 comments on commit 89b99ed

Please sign in to comment.