Skip to content

Commit

Permalink
Merge pull request #9 from tacaswell/tst_full_coverage
Browse files Browse the repository at this point in the history
Tst full coverage
  • Loading branch information
danielballan committed Jun 16, 2015
2 parents c0ea31b + 1274236 commit e1af336
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion history.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def __getitem__(self, key):
return self._cache[key]

def __setitem__(self, key, val):
if key == self.RESERVED_KEY_KEY:
raise ValueError("can not set internal keys through []")

return self.put(key, val)

def __iter__(self):
Expand All @@ -87,7 +90,7 @@ def __delitem__(self, key):
cur_keys = list(self._cache)
cur_keys.remove(key)
# INSERT SQL QUERY TO DELETE ALL INFO ABOUT THIS KEY
self[self.RESERVED_KEY_KEY] = cur_keys
self.put(self.RESERVED_KEY_KEY, cur_keys)
raise NotImplementedError()

def __len__(self):
Expand Down
7 changes: 7 additions & 0 deletions test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,10 @@ def test_get():
h.clear()
b = h.get('b', 'aardvark')
assert_equal(b, 'aardvark')


def test_protected_key():
assert_raises(ValueError, h.__getitem__,
History.RESERVED_KEY_KEY)
assert_raises(ValueError, h.__setitem__,
History.RESERVED_KEY_KEY, 'aardvark')

0 comments on commit e1af336

Please sign in to comment.