Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added tests and a gitignore file.

  • Loading branch information...
commit f2b449d1c367426d2d1edd2e225cecee22651472 1 parent 8359199
Paddy Foran authored

Showing 2 changed files with 53 additions and 0 deletions. Show diff stats Hide diff stats

  1. +11 0 .gitignore
  2. +42 0 test.py
11 .gitignore
... ... @@ -0,0 +1,11 @@
  1 +*.swp
  2 +*.pyc
  3 +config.ini
  4 +.DS_Store
  5 +*.py[cod]
  6 +*.egg
  7 +*.egg-info
  8 +dist
  9 +build
  10 +eggs
  11 +
42 test.py
... ... @@ -0,0 +1,42 @@
  1 +from iron_cache import *
  2 +import unittest
  3 +import httplib
  4 +import time
  5 +
  6 +
  7 +class TestIronCache(unittest.TestCase):
  8 +
  9 + def setUp(self):
  10 + self.cache = IronCache("test_cache")
  11 +
  12 + def test_get(self):
  13 + self.cache.put("test_item", "testing")
  14 + item = self.cache.get("test_item")
  15 + self.assertEqual(item.value, "testing")
  16 +
  17 + def test_delete(self):
  18 + self.cache.put("test_item", "will be deleted")
  19 + self.cache.delete("test_item")
  20 + self.assertRaises(httplib.HTTPException, self.cache.get,
  21 + "test_item")
  22 +
  23 + def test_increment(self):
  24 + self.cache.put("test_item", 2)
  25 + self.cache.increment("test_item")
  26 + item = self.cache.get("test_item")
  27 + self.assertEqual(item.value, 3)
  28 + self.cache.increment("test_item", amount=42)
  29 + item = self.cache.get("test_item")
  30 + self.assertEqual(item.value, 45)
  31 +
  32 + def test_decrement(self):
  33 + self.cache.put("test_item", 100)
  34 + self.cache.decrement("test_item")
  35 + item = self.cache.get("test_item")
  36 + self.assertEqual(item.value, 99)
  37 + self.cache.decrement("test_item", amount=98)
  38 + item = self.cache.get("test_item")
  39 + self.assertEqual(item.value, 1)
  40 +
  41 +if __name__ == '__main__':
  42 + unittest.main()

0 comments on commit f2b449d

Please sign in to comment.
Something went wrong with that request. Please try again.