def test_first_dict(): e = ValidationError(OrderedDict([ ('foo', 'error @ foo'), ('bar', 'error @ bar'), ('baz', 'error @ baz') ])) assert e.first() == (('foo',), 'error @ foo')
def test_first_list_in_dict(): e = ValidationError(OrderedDict([ ('foo', ['error @ foo.0', 'error @ foo.1', 'error @ foo.2']), ('bar', 'error @ bar'), ('baz', 'error @ baz') ])) assert e.first() == (('foo',), 'error @ foo.0')
def test_first_nested_dict(): e = ValidationError( OrderedDict([('foo', OrderedDict([ ('hello', 'error @ foo.hello'), ('world', 'error @ foo.world'), ])), ('bar', 'error @ bar'), ('baz', 'error @ baz')])) assert e.first() == (('foo', 'hello'), 'error @ foo.hello')
def test_first_dict_in_list(): e = ValidationError([ OrderedDict([('foo', 'error @ 0.foo'), ('bar', 'error @ 0.bar'), ('baz', 'error @ 0.baz')]), OrderedDict([('foo', 'error @ 1.foo'), ('bar', 'error @ 1.bar'), ('baz', 'error @ 1.baz')]) ]) assert e.first() == (('foo', ), 'error @ 0.foo')
def test_first_nested_dict(): e = ValidationError(OrderedDict([ ('foo', OrderedDict([ ('hello', 'error @ foo.hello'), ('world', 'error @ foo.world'), ])), ('bar', 'error @ bar'), ('baz', 'error @ baz') ])) assert e.first() == (('foo', 'hello'), 'error @ foo.hello')
def test_first_dict_in_list(): e = ValidationError([ OrderedDict([ ('foo', 'error @ 0.foo'), ('bar', 'error @ 0.bar'), ('baz', 'error @ 0.baz') ]), OrderedDict([ ('foo', 'error @ 1.foo'), ('bar', 'error @ 1.bar'), ('baz', 'error @ 1.baz') ]) ]) assert e.first() == (('foo',), 'error @ 0.foo')
def test_first_dict(): e = ValidationError( OrderedDict([('foo', 'error @ foo'), ('bar', 'error @ bar'), ('baz', 'error @ baz')])) assert e.first() == (('foo', ), 'error @ foo')
def test_first_list(): e = ValidationError(['error @ 0', 'error @ 1', 'error @ 2']) assert e.first() == (None, 'error @ 0')
def test_first_empty_list(): e = ValidationError([]) assert e.first() is None
def test_first_list_in_dict(): e = ValidationError( OrderedDict([('foo', ['error @ foo.0', 'error @ foo.1', 'error @ foo.2']), ('bar', 'error @ bar'), ('baz', 'error @ baz')])) assert e.first() == (('foo', ), 'error @ foo.0')
def test_first_list(): e = ValidationError(['error @ 0', 'error @ 1', 'error @ 2']) assert e.first() == (None, 'error @ 0')
def test_first_empty_list(): e = ValidationError([]) assert e.first() is None