Пример #1
0
def test_first_dict():
    e = ValidationError(OrderedDict([
        ('foo', 'error @ foo'),
        ('bar', 'error @ bar'),
        ('baz', 'error @ baz')
    ]))
    assert e.first() == (('foo',), 'error @ foo')
Пример #2
0
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')
Пример #3
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')
Пример #4
0
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')
Пример #5
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')
Пример #6
0
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')
Пример #7
0
def test_first_dict():
    e = ValidationError(
        OrderedDict([('foo', 'error @ foo'), ('bar', 'error @ bar'),
                     ('baz', 'error @ baz')]))
    assert e.first() == (('foo', ), 'error @ foo')
Пример #8
0
def test_first_list():
    e = ValidationError(['error @ 0', 'error @ 1', 'error @ 2'])
    assert e.first() == (None, 'error @ 0')
Пример #9
0
def test_first_empty_list():
    e = ValidationError([])
    assert e.first() is None
Пример #10
0
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')
Пример #11
0
def test_first_list():
    e = ValidationError(['error @ 0', 'error @ 1', 'error @ 2'])
    assert e.first() == (None, 'error @ 0')
Пример #12
0
def test_first_empty_list():
    e = ValidationError([])
    assert e.first() is None