How to use the wikidataintegrator.ref_handlers.test_update_retrieved_if_new.fake_itemengine1 function in wikidataintegrator

To help you get started, we’ve selected a few wikidataintegrator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SuLab / WikidataIntegrator / wikidataintegrator / ref_handlers / test_update_retrieved_if_new.py View on Github external
def test_ref_custom_diff_date_year():
    # replace retrieved date, one year away. should be updated
    statements = copy.deepcopy(orig_statements1)
    statements[0].references[0][2] = wdi_core.WDTime("+2018-04-24T00:00:00Z", prop_nr="P813", is_reference=True)
    item = fake_itemengine1(wd_item_id='Q20814663', global_ref_mode="CUSTOM", ref_handler=custom_ref_handler)
    orig = item.wd_json_representation['claims']['P698']
    item.update(data=statements)
    new = item.wd_json_representation['claims']['P698']
    require_write = not all(
        any(x.equals(y, include_ref=True) for y in item.original_statements) for x in item.statements)
    assert require_write

    frc = frc_fake_query_data_paper1(base_data_type=wdi_core.WDBaseDataType, engine=wdi_core.WDItemEngine, use_refs=True,
                                    ref_handler=custom_ref_handler)
    frc.debug = True
    assert frc.write_required(data=statements)
github SuLab / WikidataIntegrator / wikidataintegrator / ref_handlers / test_update_retrieved_if_new.py View on Github external
def test_ref_custom_diff_stated_in():
    # diff ref stated in
    statements = copy.deepcopy(orig_statements1)
    statements[0].references[0][0] = wdi_core.WDItemID("Q123", prop_nr="P813", is_reference=True)
    item = fake_itemengine1(wd_item_id='Q20814663', global_ref_mode="CUSTOM", ref_handler=custom_ref_handler)
    orig = item.wd_json_representation['claims']['P698']
    item.update(data=statements)
    new = item.wd_json_representation['claims']['P698']
    require_write = not all(
        any(x.equals(y, include_ref=True) for y in item.original_statements) for x in item.statements)
    assert require_write

    frc = frc_fake_query_data_paper1(base_data_type=wdi_core.WDBaseDataType, engine=wdi_core.WDItemEngine, use_refs=True,
                                    ref_handler=custom_ref_handler)
    frc.debug = True
    assert frc.write_required(data=statements)
github SuLab / WikidataIntegrator / wikidataintegrator / ref_handlers / test_update_retrieved_if_new.py View on Github external
def test_ref_custom():
    # custom ref mode, same retrieved date
    statements = copy.deepcopy(orig_statements1)
    item = fake_itemengine1(wd_item_id='Q20814663', global_ref_mode="CUSTOM", ref_handler=custom_ref_handler)
    orig = item.wd_json_representation['claims']['P698']
    item.update(data=statements)
    new = item.wd_json_representation['claims']['P698']
    require_write = not all(
        any(x.equals(y, include_ref=True) for y in item.original_statements) for x in item.statements)
    assert not require_write

    frc = frc_fake_query_data_paper1(base_data_type=wdi_core.WDBaseDataType, engine=wdi_core.WDItemEngine, use_refs=True,
                                    ref_handler=custom_ref_handler)
    frc.debug = True
    assert not frc.write_required(data=statements)
github SuLab / WikidataIntegrator / wikidataintegrator / ref_handlers / test_update_retrieved_if_new.py View on Github external
def test_ref_custom_diff_date_month():
    # replace retrieved date, one month away, should not be updated
    statements = copy.deepcopy(orig_statements1)
    statements[0].references[0][2] = wdi_core.WDTime("+2017-02-01T00:00:00Z", prop_nr="P813", is_reference=True)
    item = fake_itemengine1(wd_item_id='Q20814663', global_ref_mode="CUSTOM", ref_handler=custom_ref_handler)
    orig = item.wd_json_representation['claims']['P698']
    item.update(data=statements)
    new = item.wd_json_representation['claims']['P698']
    require_write = not all(
        any(x.equals(y, include_ref=True) for y in item.original_statements) for x in item.statements)
    assert not require_write

    frc = frc_fake_query_data_paper1(base_data_type=wdi_core.WDBaseDataType, engine=wdi_core.WDItemEngine, use_refs=True,
                                    ref_handler=custom_ref_handler)
    frc.debug = True
    assert not frc.write_required(data=statements)
github SuLab / WikidataIntegrator / wikidataintegrator / ref_handlers / test_update_retrieved_if_new.py View on Github external
item = fake_itemengine1(wd_item_id='Q20814663', global_ref_mode="CUSTOM", ref_handler=custom_ref_handler, append_value=['P698'])
    orig = item.wd_json_representation['claims']['P698']
    item.update(data=statements)
    new = item.wd_json_representation['claims']['P698']
    require_write = not all(
        any(x.equals(y, include_ref=True) for y in item.original_statements) for x in item.statements)
    assert require_write

    frc = frc_fake_query_data_paper1(base_data_type=wdi_core.WDBaseDataType, engine=wdi_core.WDItemEngine, use_refs=True,
                                    ref_handler=custom_ref_handler)
    frc.debug = True
    assert frc.write_required(data=statements, append_props=['P698'])

    ## nothing new
    statements = copy.deepcopy(orig_statements1)
    item = fake_itemengine1(wd_item_id='Q20814663', global_ref_mode="CUSTOM", ref_handler=custom_ref_handler,
                            append_value=['P698'])
    orig = item.wd_json_representation['claims']['P698']
    item.update(data=statements)
    new = item.wd_json_representation['claims']['P698']
    require_write = not all(
        any(x.equals(y, include_ref=True) for y in item.original_statements) for x in item.statements)
    assert not require_write

    frc = frc_fake_query_data_paper1(base_data_type=wdi_core.WDBaseDataType, engine=wdi_core.WDItemEngine,
                                     use_refs=True,
                                     ref_handler=custom_ref_handler)
    frc.debug = True
    assert not frc.write_required(data=statements, append_props=['P698'])