Beispiel #1
0
    def _process_namespace(self, schema):
        """
        :type schema: bs4.element.Tag
        """
        try:
            namespace_name = schema[NAMESPACE]
        except KeyError:
            cts_warning(
                "Incorrect schema definition {schema_definition},\n missing of namespace name",
                schema_definition=str(schema))

        for entity_soup in schema.find_all(ENTITY_TYPE):
            entity = Entity(self._metadata_container, namespace_name, entity_soup, self.qualifiers)
            self._metadata_container.entities[entity.name] = entity

        for type_soup in schema.find_all(ENUM_TYPE):
            enum_type = EnumType(self._metadata_container, namespace_name, type_soup,
                                 self.qualifiers)
            self._metadata_container.types[enum_type.name] = enum_type

        for type_soup in schema.find_all(COMPLEX_TYPE):
            complex_type = ComplexType(self._metadata_container, namespace_name, type_soup,
                                       self.qualifiers)
            self._metadata_container.types[complex_type.name] = complex_type

        for type_soup in schema.find_all(TYPE_DEFINITION):
            type_definition = TypeDefinition(self._metadata_container, namespace_name, type_soup,
                                             self.qualifiers)
            self._metadata_container.types[type_definition.name] = type_definition
    def load_entities(self, namespace_name, namespace_soup):
        entities = EntitiesContainer()
        for entity_soup in namespace_soup.find_all(ENTITY_TYPE):
            entity = Entity(namespace_name, entity_soup)
            entities[entity.name] = entity

        return entities
Beispiel #3
0
    def test_entity_allow_additional_properties(self):
        entity_doc = """
        <EntityType Name="entity_name">
            <Annotation Term="OData.AdditionalProperties" Bool="true"/>
        </EntityType>
        """

        entity_soup = self._get_entity_soup_from_entity_text(entity_doc)

        entity = Entity(MetadataContainer(), "", entity_soup)
        self.assertTrue(entity.allow_additional_properties)
Beispiel #4
0
    def test_entity_navigation_property(self):
        entity_doc = """
        <EntityType Name="entity_name">
            <NavigationProperty Name="property_name" type="property_type" />
        </EntityType>
        """

        entity_soup = self._get_entity_soup_from_entity_text(entity_doc)

        entity = Entity(MetadataContainer(), "", entity_soup)
        self.assertFalse(entity.properties)
        self.assertEqual(len(entity.navigation_properties), 1)
Beispiel #5
0
    def test_empty_entity(self):
        namespace_name = "namespace_name"
        entity_name = "entity_name"
        entity_doc = """
        <EntityType Name="{entity_name}" />
        """.format(entity_name=entity_name)

        entity_soup = self._get_entity_soup_from_entity_text(entity_doc)

        entity = Entity(MetadataContainer(), namespace_name, entity_soup)
        self.assertEqual(entity.name, ".".join([namespace_name, entity_name]))
        self.assertTrue(entity.allow_additional_properties)
        self.assertIsNone(entity.base_type)
        self.assertFalse(entity.abstract)
        self.assertFalse(entity.annotations)
        self.assertFalse(entity.properties)
        self.assertFalse(entity.navigation_properties)