def test_parse_property_identifier(self):
        thing = {'@id': schema_org_id('Thing')}
        intangible = {
            '@id': schema_org_id('Intangible'),
            'rdfs:subClassOf': thing
        }
        structured_value = {
            '@id': schema_org_id('StructuredValue'),
            'rdfs:subClassOf': intangible
        }
        property_value = {
            '@id': schema_org_id('PropertyValue'),
            'rdfs:subClassOf': structured_value
        }
        number = {
            '@id': schema_org_id('Number'),
            '@type': [schema_org_id('DataType'), 'rdfs:Class']
        }
        integer = {'@id': schema_org_id('Integer'), 'rdfs:subClassOf': number}
        identifier = {
            '@id': schema_org_id('Identifier'),
            schema_org_id('rangeIncludes'): [property_value, integer, number]
        }
        schema = {
            '@graph': [
                thing, intangible, structured_value, property_value, number,
                integer, identifier
            ]
        }

        names = {"http://schema.org/Identifier": 1234, "Identifier": 1235}

        self.assertEqual(
            generate_schema_org_code.parse_property(identifier, schema, names),
            {
                'name': 'Identifier',
                'name_hash': 1235,
                'has_number': True,
                'thing_types': [property_value['@id']],
                'enum_types': []
            })
예제 #2
0
    def test_parse_property_identifier(self):
        thing = {'@id': schema_org_id('Thing')}
        intangible = {
            '@id': schema_org_id('Intangible'),
            'rdfs:subClassOf': thing
        }
        structured_value = {
            '@id': schema_org_id('StructuredValue'),
            'rdfs:subClassOf': intangible
        }
        property_value = {
            '@id': schema_org_id('PropertyValue'),
            'rdfs:subClassOf': structured_value
        }
        text = {
            '@id': schema_org_id('Text'),
            '@type': [schema_org_id('DataType'), 'rdfs:Class']
        }
        url = {'@id': schema_org_id('URL'), 'rdfs:subClassOf': text}
        identifier = {
            '@id': schema_org_id('Identifier'),
            schema_org_id('rangeIncludes'): [property_value, url, text]
        }
        schema = {
            '@graph': [
                thing, intangible, structured_value, property_value, text, url,
                identifier
            ]
        }

        self.assertEqual(
            generate_schema_org_code.parse_property(identifier, schema), {
                'name': 'Identifier',
                'has_text': True,
                'thing_types': [property_value['@id']]
            })