-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate builders against both top level data type specs and inner sp…
…ecs (#609) * Validate builders against both top level data type specs and inner specs * Fix #585 * Ref #542 * Builder can now be validated against more than one spec in order to validate against additional fields added to inner data types * Also make validation Errors comparable as a way to remove duplicates that can sometimes be generated * Update changelog * Ref #585 * Fix pynwb validation errors related to reference and compound data types * Ref #585 * This is just a workaround for checking the data_type of BuilderH5ReferenceDataset and BuilderH5TableDataset objects * Plan to add unit tests after some discussion to validate the approach * Remove validator reference to H5-specific classes and add unit tests * use ReferenceResolver instead of referencing BuilderH5ReferenceDataset or BuilderH5TableDataset * Fix #585 * Update tests/unit/validator_tests/test_validate.py * Update tests/unit/validator_tests/test_validate.py Co-authored-by: Ryan Ly <rly@lbl.gov>
- Loading branch information
Showing
5 changed files
with
327 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from unittest import TestCase | ||
|
||
from hdmf.validate.errors import Error | ||
|
||
|
||
class TestErrorEquality(TestCase): | ||
def test_self_equality(self): | ||
"""Verify that one error equals itself""" | ||
error = Error('foo', 'bad thing', 'a.b.c') | ||
self.assertEqual(error, error) | ||
|
||
def test_equality_with_same_field_values(self): | ||
"""Verify that two errors with the same field values are equal""" | ||
err1 = Error('foo', 'bad thing', 'a.b.c') | ||
err2 = Error('foo', 'bad thing', 'a.b.c') | ||
self.assertEqual(err1, err2) | ||
|
||
def test_not_equal_with_different_reason(self): | ||
"""Verify that two errors with a different reason are not equal""" | ||
err1 = Error('foo', 'bad thing', 'a.b.c') | ||
err2 = Error('foo', 'something else', 'a.b.c') | ||
self.assertNotEqual(err1, err2) | ||
|
||
def test_not_equal_with_different_name(self): | ||
"""Verify that two errors with a different name are not equal""" | ||
err1 = Error('foo', 'bad thing', 'a.b.c') | ||
err2 = Error('bar', 'bad thing', 'a.b.c') | ||
self.assertNotEqual(err1, err2) | ||
|
||
def test_not_equal_with_different_location(self): | ||
"""Verify that two errors with a different location are not equal""" | ||
err1 = Error('foo', 'bad thing', 'a.b.c') | ||
err2 = Error('foo', 'bad thing', 'd.e.f') | ||
self.assertNotEqual(err1, err2) | ||
|
||
def test_equal_with_no_location(self): | ||
"""Verify that two errors with no location but the same name are equal""" | ||
err1 = Error('foo', 'bad thing') | ||
err2 = Error('foo', 'bad thing') | ||
self.assertEqual(err1, err2) | ||
|
||
def test_not_equal_with_overlapping_name_when_no_location(self): | ||
"""Verify that two errors with an overlapping name but no location are | ||
not equal | ||
""" | ||
err1 = Error('foo', 'bad thing') | ||
err2 = Error('x/y/foo', 'bad thing') | ||
self.assertNotEqual(err1, err2) | ||
|
||
def test_equal_with_overlapping_name_when_location_present(self): | ||
"""Verify that two errors with an overlapping name and a location are equal""" | ||
err1 = Error('foo', 'bad thing', 'a.b.c') | ||
err2 = Error('x/y/foo', 'bad thing', 'a.b.c') | ||
self.assertEqual(err1, err2) |
Oops, something went wrong.