From ca16b016287d013f41abd033cb95085762ac96ca Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Thu, 25 Jul 2013 16:15:50 +0200 Subject: [PATCH] [#1117] Add another ignore_missing test --- ckan/new_tests/lib/navl/test_validators.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ckan/new_tests/lib/navl/test_validators.py b/ckan/new_tests/lib/navl/test_validators.py index a3eaf3a5ee5..1d0f526b273 100644 --- a/ckan/new_tests/lib/navl/test_validators.py +++ b/ckan/new_tests/lib/navl/test_validators.py @@ -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.