Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tst full coverage #9

Merged
merged 2 commits into from
Jun 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')