DefaultValidator doesn't raise exceptions when validation fails

Bug #1165175 reported by Max Brustkern
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
UTAH
Fix Released
Medium
Javier Collado

Bug Description

DefaultValidator will validate an empty dict as a valid control file without raising an exception:

>>> from jsonschema import Validator
>>> from utah.client.common import DefaultValidator
>>> from utah.client.testcase import TestCase
>>> schema = TestCase('', '/usr/share/utah/client/examples/examples/test_one', '').CONTROL_SCHEMA
>>> DefaultValidator().validate(dict(), schema)
>>> Validator().validate(dict(), schema)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/jsonschema.py", line 332, in validate
    raise error
jsonschema.ValidationError: 'description' is a required property
>>>

Related branches

Revision history for this message
Max Brustkern (nuclearbob) wrote :

I think we should have probably at least three tests for the DefaultValidator:
test that it validates valid data
test that it fails to validate bad data
test that it populates a default if needed
and maybe
test that not supplying a value with a default doesn't cause validation to fail?

Additionally, in test_testcase, I think we should test for:
missing field
extra field
bad reboot
bad timeout
bad type

Changed in utah:
assignee: nobody → Javier Collado (javier.collado)
status: New → Triaged
importance: Undecided → Medium
Changed in utah:
status: Triaged → In Progress
Changed in utah:
status: In Progress → Fix Committed
Changed in utah:
milestone: none → 0.12
Changed in utah:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.