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)
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)
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)
class TestSchema(SequenceSchema): sequence = [ ElementSchema('name', validator=NCName()), ElementSchema('count', validator=PositiveInteger()) ]
def test_ncname_pass(): validator_inst = NCName() value = 'Test-NCName_0' actual = validator_inst.to_python(value) nose.tools.eq_(actual, value)
def test_ncname_whitespace_fail(): validator_inst = NCName() value = 'ns:Test-NCName 0' validator_inst.to_python(value)
def test_build_ncname_pass(): actual = NCName().build() nose.tools.eq_(actual, 'NCName')