Debian Codegraph @

tests/unit/validator_tests/test_errors.py

raw
1 from unittest import TestCase
2
3 from hdmf.validate.errors import Error
4
5
6 class TestErrorEquality(TestCase):
7 def test_self_equality(self):
8 """Verify that one error equals itself"""
9 error = Error('foo', 'bad thing', 'a.b.c')
10 self.assertEqual(error, error)
11
12 def test_equality_with_same_field_values(self):
13 """Verify that two errors with the same field values are equal"""
14 err1 = Error('foo', 'bad thing', 'a.b.c')
15 err2 = Error('foo', 'bad thing', 'a.b.c')
16 self.assertEqual(err1, err2)
17
18 def test_not_equal_with_different_reason(self):
19 """Verify that two errors with a different reason are not equal"""
20 err1 = Error('foo', 'bad thing', 'a.b.c')
21 err2 = Error('foo', 'something else', 'a.b.c')
22 self.assertNotEqual(err1, err2)
23
24 def test_not_equal_with_different_name(self):
25 """Verify that two errors with a different name are not equal"""
26 err1 = Error('foo', 'bad thing', 'a.b.c')
27 err2 = Error('bar', 'bad thing', 'a.b.c')
28 self.assertNotEqual(err1, err2)
29
30 def test_not_equal_with_different_location(self):
31 """Verify that two errors with a different location are not equal"""
32 err1 = Error('foo', 'bad thing', 'a.b.c')
33 err2 = Error('foo', 'bad thing', 'd.e.f')
34 self.assertNotEqual(err1, err2)
35
36 def test_equal_with_no_location(self):
37 """Verify that two errors with no location but the same name are equal"""
38 err1 = Error('foo', 'bad thing')
39 err2 = Error('foo', 'bad thing')
40 self.assertEqual(err1, err2)
41
42 def test_not_equal_with_overlapping_name_when_no_location(self):
43 """Verify that two errors with an overlapping name but no location are
44 not equal
45 """
46 err1 = Error('foo', 'bad thing')
47 err2 = Error('x/y/foo', 'bad thing')
48 self.assertNotEqual(err1, err2)
49
50 def test_equal_with_overlapping_name_when_location_present(self):
51 """Verify that two errors with an overlapping name and a location are equal"""
52 err1 = Error('foo', 'bad thing', 'a.b.c')
53 err2 = Error('x/y/foo', 'bad thing', 'a.b.c')
54 self.assertEqual(err1, err2)