Beispiel #1
0
def test_element_schema_build_no_value_with_star_attribute_pass():
    es = ElementSchema('name',
                       validator=NCName(),
                       attributes=[
                           ElementSchema('id', validator=ID()),
                           ElementSchema('*', validator=None),
                           ElementSchema('offset',
                                         validator=PositiveInteger()),
                       ])
    path = '/name-0,NCName,'
    stores = Stores()
    actual = es.build(path=path, stores=stores)
    expected = Element('name',
                       value='NCName',
                       path=path,
                       attributes=OrderedDict([('id', 'testId0'),
                                               ('offset', 1)]))
    nose.tools.eq_(actual, expected)
Beispiel #2
0
def test_element_schema_tp_python_element_None_pass():
    es = ElementSchema('test', validator=NCName(), minOccurs=0)
    el = Element('test', value=None, path='/')
    value = es.to_python(el)
    nose.tools.eq_(value, el)
Beispiel #3
0
def test_element_schema_build_no_value_no_attributes_pass():
    es = ElementSchema('name', validator=NCName())
    path = '/name-0,NCName,'
    actual = es.build(path=path)
    expected = Element('name', value='NCName', path=path)
    nose.tools.eq_(actual, expected)
Beispiel #4
0
 class TestSchema(SequenceSchema):
     sequence = [
         ElementSchema('name', validator=NCName()),
         ElementSchema('count', validator=PositiveInteger())
     ]
Beispiel #5
0
def test_ncname_pass():
    validator_inst = NCName()
    value = 'Test-NCName_0'
    actual = validator_inst.to_python(value)
    nose.tools.eq_(actual, value)
Beispiel #6
0
def test_ncname_whitespace_fail():
    validator_inst = NCName()
    value = 'ns:Test-NCName 0'
    validator_inst.to_python(value)
Beispiel #7
0
def test_build_ncname_pass():
    actual = NCName().build()
    nose.tools.eq_(actual, 'NCName')