Skip to content

Commit

Permalink
[#1117] Add another ignore_missing test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hammond committed Jul 25, 2013
1 parent a956b1f commit ca16b01
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions ckan/new_tests/lib/navl/test_validators.py
Expand Up @@ -47,6 +47,26 @@ def test_ignore_missing_with_missing(self):
# ignore_missing should remove the item from the dict.
assert key not in data

def test_ignore_missing_without_key(self):
'''If key is not in data ignore_missing() should raise StopOnError.'''

import ckan.lib.navl.dictization_functions as df
import ckan.lib.navl.validators as validators

key = ('foo',)
data = {}
errors = {key: []}

with nose.tools.assert_raises(df.StopOnError):
validators.ignore_missing(
key=key,
data=data,
errors=errors,
context={})

# ignore_missing should remove the item from the dict.
assert key not in data

def test_ignore_missing_with_a_value(self):
'''If data[key] is neither None or missing, ignore_missing() should do
nothing.
Expand Down

0 comments on commit ca16b01

Please sign in to comment.