Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_type_parsing():
"""Test parsing of type names"""
type_info = Types.parse_type_name('Edm.Boolean')
assert type_info[0] is None
assert type_info[1] == 'Edm.Boolean'
assert not type_info[2]
type_info = Types.parse_type_name('SomeType')
assert type_info[0] is None
assert type_info[1] == 'SomeType'
assert not type_info[2]
type_info = Types.parse_type_name('SomeNamespace.SomeType')
assert type_info[0] == 'SomeNamespace'
assert type_info[1] == 'SomeType'
assert not type_info[2]
# collections
type_info = Types.parse_type_name('Collection(Edm.String)')
assert type_info[0] is None
assert type_info[1] == 'Edm.String'
assert type_info[2]
type_info = Types.parse_type_name('Collection(SomeType)')
assert type_info[0] is None
assert type_info[1] == 'SomeType'
assert type_info[2]
type_info = Types.parse_type_name('Collection(SomeNamespace.SomeType)')
def test_type_parsing():
"""Test parsing of type names"""
type_info = Types.parse_type_name('Edm.Boolean')
assert type_info[0] is None
assert type_info[1] == 'Edm.Boolean'
assert not type_info[2]
type_info = Types.parse_type_name('SomeType')
assert type_info[0] is None
assert type_info[1] == 'SomeType'
assert not type_info[2]
type_info = Types.parse_type_name('SomeNamespace.SomeType')
assert type_info[0] == 'SomeNamespace'
assert type_info[1] == 'SomeType'
assert not type_info[2]
# collections
type_info = Types.parse_type_name('Collection(Edm.String)')
def test_type_parsing():
"""Test parsing of type names"""
type_info = Types.parse_type_name('Edm.Boolean')
assert type_info[0] is None
assert type_info[1] == 'Edm.Boolean'
assert not type_info[2]
type_info = Types.parse_type_name('SomeType')
assert type_info[0] is None
assert type_info[1] == 'SomeType'
assert not type_info[2]
type_info = Types.parse_type_name('SomeNamespace.SomeType')
assert type_info[0] == 'SomeNamespace'
assert type_info[1] == 'SomeType'
assert not type_info[2]
# collections
type_info = Types.parse_type_name('Collection(Edm.String)')
assert type_info[0] is None
assert type_info[1] == 'Edm.String'
assert type_info[2]
type_info = Types.parse_type_name('Collection(SomeType)')
assert type_info[0] is None
assert type_info[1] == 'SomeType'
assert not type_info[2]
type_info = Types.parse_type_name('SomeNamespace.SomeType')
assert type_info[0] == 'SomeNamespace'
assert type_info[1] == 'SomeType'
assert not type_info[2]
# collections
type_info = Types.parse_type_name('Collection(Edm.String)')
assert type_info[0] is None
assert type_info[1] == 'Edm.String'
assert type_info[2]
type_info = Types.parse_type_name('Collection(SomeType)')
assert type_info[0] is None
assert type_info[1] == 'SomeType'
assert type_info[2]
type_info = Types.parse_type_name('Collection(SomeNamespace.SomeType)')
assert type_info[0] == 'SomeNamespace'
assert type_info[1] == 'SomeType'
assert type_info[2]
assert type_info[0] == 'SomeNamespace'
assert type_info[1] == 'SomeType'
assert not type_info[2]
# collections
type_info = Types.parse_type_name('Collection(Edm.String)')
assert type_info[0] is None
assert type_info[1] == 'Edm.String'
assert type_info[2]
type_info = Types.parse_type_name('Collection(SomeType)')
assert type_info[0] is None
assert type_info[1] == 'SomeType'
assert type_info[2]
type_info = Types.parse_type_name('Collection(SomeNamespace.SomeType)')
assert type_info[0] == 'SomeNamespace'
assert type_info[1] == 'SomeType'
assert type_info[2]
def from_etree(function_import_node, config: Config):
name = function_import_node.get('Name')
entity_set = function_import_node.get('EntitySet')
http_method = metadata_attribute_get(function_import_node, 'HttpMethod')
rt_type = function_import_node.get('ReturnType')
rt_info = None if rt_type is None else Types.parse_type_name(rt_type)
print(name, rt_type, rt_info)
parameters = dict()
for param in function_import_node.xpath('edm:Parameter', namespaces=config.namespaces):
param_name = param.get('Name')
param_type_info = Types.parse_type_name(param.get('Type'))
param_nullable = param.get('Nullable')
param_max_length = param.get('MaxLength')
param_precision = param.get('Precision')
param_scale = param.get('Scale')
param_mode = param.get('Mode')
parameters[param_name] = FunctionImportParameter(param_name, param_type_info, param_nullable,
param_max_length, param_precision, param_scale, param_mode)
return FunctionImport(name, rt_info, entity_set, parameters, http_method)
def from_etree(entity_type_property_node):
return StructTypeProperty(
entity_type_property_node.get('Name'),
Types.parse_type_name(entity_type_property_node.get('Type')),
entity_type_property_node.get('Nullable'),
entity_type_property_node.get('MaxLength'),
entity_type_property_node.get('Precision'),
entity_type_property_node.get('Scale'),
# TODO: create a class SAP attributes
sap_attribute_get_bool(entity_type_property_node, 'unicode', True),
sap_attribute_get_string(entity_type_property_node, 'label'),
sap_attribute_get_bool(entity_type_property_node, 'creatable', True),
sap_attribute_get_bool(entity_type_property_node, 'updatable', True),
sap_attribute_get_bool(entity_type_property_node, 'sortable', True),
sap_attribute_get_bool(entity_type_property_node, 'filterable', True),
sap_attribute_get_string(entity_type_property_node, 'filter-restriction'),
sap_attribute_get_bool(entity_type_property_node, 'required-in-filter', False),
sap_attribute_get_string(entity_type_property_node, 'text'),
sap_attribute_get_bool(entity_type_property_node, 'visible', True),
sap_attribute_get_string(entity_type_property_node, 'display-format'),
def from_etree(end_role_node):
entity_type_info = Types.parse_type_name(end_role_node.get('Type'))
multiplicity = end_role_node.get('Multiplicity')
role = end_role_node.get('Role')
return EndRole(entity_type_info, multiplicity, role)
def from_etree(entity_set_node):
name = entity_set_node.get('Name')
et_info = Types.parse_type_name(entity_set_node.get('EntityType'))
# TODO: create a class SAP attributes
addressable = sap_attribute_get_bool(entity_set_node, 'addressable', True)
creatable = sap_attribute_get_bool(entity_set_node, 'creatable', True)
updatable = sap_attribute_get_bool(entity_set_node, 'updatable', True)
deletable = sap_attribute_get_bool(entity_set_node, 'deletable', True)
searchable = sap_attribute_get_bool(entity_set_node, 'searchable', False)
countable = sap_attribute_get_bool(entity_set_node, 'countable', True)
pageable = sap_attribute_get_bool(entity_set_node, 'pageable', True)
topable = sap_attribute_get_bool(entity_set_node, 'topable', pageable)
req_filter = sap_attribute_get_bool(entity_set_node, 'requires-filter', False)
label = sap_attribute_get_string(entity_set_node, 'label')
return EntitySet(name, et_info, addressable, creatable, updatable, deletable, searchable, countable, pageable,
topable, req_filter, label)