Skip to content

Commit

Permalink
[#1117] Make a unit test more realistic
Browse files Browse the repository at this point in the history
Make it use the _data() and _errors() helper functions to get more
realistic (non-empty) data and errors dicts. This just makes the test a
little more thorough and realistic.
  • Loading branch information
Sean Hammond committed Jul 26, 2013
1 parent 2f8e74a commit e5d37e1
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions ckan/new_tests/lib/navl/test_validators.py
Expand Up @@ -86,17 +86,23 @@ def test_ignore_missing_with_a_value(self):
'''
import ckan.lib.navl.validators as validators

key = ('foo',)
data = {key: 'bar'}
errors = {key: []}
key = ('key to be validated',)
data = _data()
data[key] = 'value to be validated'
errors = _errors()
errors[key] = []

# Make copies of the data and errors dicts for asserting later.
original_data = copy.deepcopy(data)
original_errors = copy.deepcopy(errors)

result = validators.ignore_missing(key=key, data=data, errors=errors,
context={})

assert result is None

# ignore_missing shouldn't remove or modify the value.
assert data.get(key) == 'bar'
assert data == original_data, ("ignore_missing() shouldn't modify the "
"data dict")

# ignore_missing shouldn't add any errors.
assert errors[key] == []
assert errors == original_errors, ("ignore_missing() shouldn't modify "
"the errors dict")

0 comments on commit e5d37e1

Please sign in to comment.