def test_boolean_default(self): tns = 'some_ns' class SomeGuy(ComplexModel): __namespace__ = tns bald = Boolean(default=True) schema = get_schema_documents([SomeGuy], tns)['tns'] print(etree.tostring(schema, pretty_print=True)) objects = parse_schema_element(schema) pprint(objects[tns].types) NewGuy = objects['some_ns'].types["SomeGuy"] assert NewGuy._type_info['bald'].Attributes.default == True
def test_attribute(self): tns = 'some_ns' class SomeGuy(ComplexModel): __namespace__ = tns name = XmlAttribute(Unicode) schema = get_schema_documents([SomeGuy], tns)['tns'] print etree.tostring(schema, pretty_print=True) objects = parse_schema_element(schema) pprint(objects[tns].types) NewGuy = objects['some_ns'].types["SomeGuy"] assert NewGuy._type_info['name'].type is Unicode
def test_attribute(self): tns = 'some_ns' class SomeGuy(ComplexModel): __namespace__ = tns name = XmlAttribute(Unicode) schema = get_schema_documents([SomeGuy], tns)['tns'] print(etree.tostring(schema, pretty_print=True)) objects = parse_schema_element(schema) pprint(objects[tns].types) NewGuy = objects['some_ns'].types["SomeGuy"] assert NewGuy._type_info['name'].type is Unicode
def test_attribute_with_customized_type(self): tns = 'some_ns' class SomeGuy(ComplexModel): __namespace__ = tns name = XmlAttribute(Unicode(default="aa")) schema = get_schema_documents([SomeGuy], tns)['tns'] print(etree.tostring(schema, pretty_print=True)) objects = parse_schema_element(schema) pprint(objects[tns].types) NewGuy = objects['some_ns'].types["SomeGuy"] assert NewGuy._type_info['name'].type.__orig__ is Unicode assert NewGuy._type_info['name'].type.Attributes.default == "aa"
def test_attribute_with_customized_type(self): tns = 'some_ns' class SomeGuy(ComplexModel): __namespace__ = tns name = XmlAttribute(Unicode(default="aa")) schema = get_schema_documents([SomeGuy], tns)['tns'] print etree.tostring(schema, pretty_print=True) objects = parse_schema_element(schema) pprint(objects[tns].types) NewGuy = objects['some_ns'].types["SomeGuy"] assert NewGuy._type_info['name'].type.__orig__ is Unicode assert NewGuy._type_info['name'].type.Attributes.default == "aa"
def test_customized_unicode(self): tns = 'some_ns' class SomeGuy(ComplexModel): __namespace__ = tns name = Unicode(max_len=10, pattern="a", min_len=5, default="aa") schema = get_schema_documents([SomeGuy], tns)['tns'] print(etree.tostring(schema, pretty_print=True)) objects = parse_schema_element(schema) pprint(objects[tns].types) NewGuy = objects['some_ns'].types["SomeGuy"] assert NewGuy._type_info['name'].Attributes.max_len == 10 assert NewGuy._type_info['name'].Attributes.min_len == 5 assert NewGuy._type_info['name'].Attributes.pattern == "a" assert NewGuy._type_info['name'].Attributes.default == "aa"
def test_simple(self): tns = 'some_ns' class SomeGuy(ComplexModel): __namespace__ = 'some_ns' id = Integer schema = get_schema_documents([SomeGuy], tns)['tns'] print(etree.tostring(schema, pretty_print=True)) objects = parse_schema_element(schema) pprint(objects[tns].types) NewGuy = objects[tns].types["SomeGuy"] assert NewGuy.get_type_name() == SomeGuy.get_type_name() assert NewGuy.get_namespace() == SomeGuy.get_namespace() assert dict(NewGuy._type_info) == dict(SomeGuy._type_info)
def _get_schema(self, *args): schema_doc = get_schema_documents(args)['tns'] return parse_schema_element(schema_doc)