Skip to content

Commit

Permalink
Added tests and a gitignore file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paddy Foran committed Jul 21, 2012
1 parent 8359199 commit f2b449d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.swp
*.pyc
config.ini
.DS_Store
*.py[cod]
*.egg
*.egg-info
dist
build
eggs

42 changes: 42 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -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.