Permalink
Browse files

Added tests and a gitignore file.

  • Loading branch information...
1 parent 8359199 commit f2b449d1c367426d2d1edd2e225cecee22651472 Paddy Foran committed Jul 21, 2012
Showing with 53 additions and 0 deletions.
  1. +11 −0 .gitignore
  2. +42 −0 test.py
View
@@ -0,0 +1,11 @@
+*.swp
+*.pyc
+config.ini
+.DS_Store
+*.py[cod]
+*.egg
+*.egg-info
+dist
+build
+eggs
+
View
42 test.py
@@ -0,0 +1,42 @@
+from iron_cache import *
+import unittest
+import httplib
+import time
+
+
+class TestIronCache(unittest.TestCase):
+
+ def setUp(self):
+ self.cache = IronCache("test_cache")
+
+ def test_get(self):
+ self.cache.put("test_item", "testing")
+ item = self.cache.get("test_item")
+ self.assertEqual(item.value, "testing")
+
+ def test_delete(self):
+ self.cache.put("test_item", "will be deleted")
+ self.cache.delete("test_item")
+ self.assertRaises(httplib.HTTPException, self.cache.get,
+ "test_item")
+
+ def test_increment(self):
+ self.cache.put("test_item", 2)
+ self.cache.increment("test_item")
+ item = self.cache.get("test_item")
+ self.assertEqual(item.value, 3)
+ self.cache.increment("test_item", amount=42)
+ item = self.cache.get("test_item")
+ self.assertEqual(item.value, 45)
+
+ def test_decrement(self):
+ self.cache.put("test_item", 100)
+ self.cache.decrement("test_item")
+ item = self.cache.get("test_item")
+ self.assertEqual(item.value, 99)
+ self.cache.decrement("test_item", amount=98)
+ item = self.cache.get("test_item")
+ self.assertEqual(item.value, 1)
+
+if __name__ == '__main__':
+ unittest.main()

0 comments on commit f2b449d

Please sign in to comment.