示例#1
0
    def test_wd_geoshape(self):
        dt = wdi_core.WDGeoShape(value='Data:Inner_West_Light_Rail_stops.map', prop_nr='P43')

        dt_json = dt.get_json_representation()

        if not dt_json['mainsnak']['datatype'] == 'geo-shape':
            raise

        value = dt_json['mainsnak']['datavalue']

        if not value['value'] == 'Data:Inner_West_Light_Rail_stops.map':
            raise

        if not value['type'] == 'string':
            raise
示例#2
0
    def test_new_item_creation(self):
        data = [
            wdi_core.WDString(value='test', prop_nr='P1'),
            wdi_core.WDString(value='test1', prop_nr='P2'),
            wdi_core.WDMath("xxx", prop_nr="P3"),
            wdi_core.WDExternalID("xxx", prop_nr="P4"),
            wdi_core.WDItemID("Q123", prop_nr="P5"),
            wdi_core.WDTime('+%Y-%m-%dT%H:%M:%SZ', "P6"),
            wdi_core.WDUrl("http://www.google.com", "P7"),
            wdi_core.WDMonolingualText("xxx", prop_nr="P8"),
            wdi_core.WDQuantity(5, prop_nr="P9"),
            wdi_core.WDQuantity(5, upper_bound=9, lower_bound=2,
                                prop_nr="P10"),
            wdi_core.WDCommonsMedia("xxx", prop_nr="P11"),
            wdi_core.WDGlobeCoordinate(1.2345, 1.2345, 12, prop_nr="P12"),
            wdi_core.WDGeoShape("xxx", prop_nr="P13"),
            wdi_core.WDProperty("P123", "P14")
        ]
        core_props = set(["P{}".format(x) for x in range(20)])

        for d in data:
            item = wdi_core.WDItemEngine(item_name='dae',
                                         domain="szadf",
                                         data=[d],
                                         core_props=core_props)
            assert item.get_wd_json_representation()
            item = wdi_core.WDItemEngine(item_name='dae',
                                         domain="szadf",
                                         data=[d],
                                         core_props=set())
            assert item.get_wd_json_representation()

        item = wdi_core.WDItemEngine(item_name='dae',
                                     domain="szadf",
                                     data=data,
                                     core_props=core_props)
        assert item.get_wd_json_representation()
        item = wdi_core.WDItemEngine(item_name='dae',
                                     domain="szadf",
                                     data=data,
                                     core_props=set())
        assert item.get_wd_json_representation()