def test_max_len(self): StrictType = String(max_len=3) self.assertEquals(StrictType.validate_string(StrictType, 'a'), True) self.assertEquals(StrictType.validate_string(StrictType, 'aaa'), True) self.assertEquals(StrictType.validate_string(StrictType, 'aaaa'), False)
def test_unicode(self): s = u'\x34\x55\x65\x34' self.assertEquals(4, len(s)) element = etree.Element('test') String.to_parent_element(s, 'test_ns', element) element = element[0] value = String.from_xml(element) self.assertEquals(value, s)
class SomeService(ServiceBase): @srpc(String(pattern='a')) def some_method(s): pass @srpc(String(pattern='a', max_occurs=2)) def some_other_method(s): pass
def test_string(self): s = String() element = etree.Element('test') String.to_parent_element('value', ns_test, element) element=element[0] self.assertEquals(element.text, 'value') value = String.from_xml(element) self.assertEquals(value, 'value')
def test_string(self): s = String() element = etree.Element('test') String.to_parent_element('value', ns_test, element) element = element[0] self.assertEquals(element.text, 'value') value = String.from_xml(element) self.assertEquals(value, 'value')
class SisMsg(ComplexModel): """Container with metadata for Jiva integration messages carried in the MQ payload. """ data_source = String(nillable=False, min_occurs=1, max_occurs=1, max_len=50) direction = String(nillable=False, min_occurs=1, max_occurs=1, max_len=50) interface_name = String(nillable=False, min_occurs=1, max_occurs=1, max_len=50) crt_dt = DateTime(nillable=False)
class NonNillableClass(ComplexModel): __namespace__ = "hunk.sunk" nillable = False min_occurs = 1 dt = DateTime(min_occurs=1, nillable=False) i = Integer(nillable=False) s = String(min_len=1, nillable=False)
class User(ComplexModel): __namespace__ = 'rpclib.examples.user_manager' user_id = Integer user_name = String first_name = String last_name = String email = String(pattern=r'[a-z0-9._%+-]+@[a-z0-9.-]+\.[A-Z]{2,4}') permissions = Array(Permission)
def test_string(self): s = String() element = etree.Element('test') XmlObject().to_parent_element(String, 'value', ns_test, element) element = element[0] self.assertEquals(element.text, 'value') value = XmlObject().from_element(String, element) self.assertEquals(value, 'value')
def test_pattern(self): StrictType = String(pattern='a') self.assertEquals(StrictType.validate_string(StrictType, 'a'), True) self.assertEquals(StrictType.validate_string(StrictType, 'b'), False)
class Preferences(ComplexModel): __namespace__ = 'rpclib.examples.authentication' language = String(max_len=2) time_zone = String
class SomeService(ServiceBase): @srpc(String(pattern='a')) def some_method(s): pass
class SomeService(ServiceBase): @srpc(String(max_occurs='unbounded'), _returns=String) def some_call(s): return '\n'.join(s)