# Path: matcher/wikidata.py
# def get_query(q, south, north, west, east):
# def query_map(prefix, **kwargs):
# def bbox_query_map(south, north, west, east, **kwargs):
# def point_query_map(lat, lon, radius_m):
# def get_enwiki_query(*args):
# def get_enwiki_hq_query(*args):
# def get_item_tag_query(*args):
# def get_hq_item_tag_query(*args):
# def get_point_query(lat, lon, radius):
# def run_query(query, name=None, return_json=True, timeout=None, send_error_mail=False):
#     def error_mail(subject, r):
# def flatten_criteria(items):
# def wd_uri_to_id(value):
# def wd_to_qid(wd):
# def wd_uri_to_qid(value):
# def enwiki_url_to_title(url):
# def parse_enwiki_query(rows):
# def drop_tag_prefix(v):
# def parse_item_tag_query(rows, items):
# def page_banner_from_entity(entity, **kwargs):
# def entity_label(entity, language=None):
# def entity_description(entity, language=None):
# def names_from_entity(entity, skip_lang=None):
# def parse_osm_keys(rows):
# def get_location_hierarchy(qid, name=None):
# def up_one_level(qid, name=None):
# def next_level_types(types):
# def isa_list(types):
# def get_next_level_query(qid, entity, language='en', name=None):
# def next_level_places(qid, entity, language=None, query=None, name=None):
# def query_for_items(query, items):
# def get_item_labels(items):
# def row_qid_and_label(row, name):
# def get_isa(items, name=None):
# def item_types_graph(items, name=None, rows=None):
# def find_superclasses(items, name=None):
# def claim_value(claim):
# def country_iso_codes_from_qid(qid):
#     def __init__(self, qid, entity):
#     def retrieve_item(cls, qid):
#     def claims(self):
#     def labels(self):
#     def aliases(self):
#     def sitelinks(self):
#     def get_sitelinks(self):
#     def remove_badges(self):
#     def first_claim_value(self, key):
#     def has_coords(self):
#     def has_earth_coords(self):
#     def coords(self):
#     def nrhp(self):
#     def get_oql(self, criteria, radius):
#     def trim_location_from_names(self, wikidata_names):
#     def osm_key_query(self):
#     def osm_keys(self):
#     def languages_from_country(self):
#     def query_language_from_country(self):
#     def label(self, lang=None):
#     def names(self):
#     def is_a(self):
#     def is_a_detail(self):
#     def is_proposed(self):
#     def criteria(self):
#     def report_broken_wikidata_osm_tags(self):
#     def find_nrhp_match(self, overpass_reply):
#     def parse_item_query(self, criteria, overpass_reply):
# class WikidataItem:


from matcher import wikidata
import pytest
import vcr
    assert entity.label() == 'Natuurmuseum Brabant'

def test_names_from_entity():
    names = wikidata.names_from_entity(test_entity)

    expect = {
        'The Eiffel Tower': [('alias', 'en')],
        'Eiffel Tower': [('label', 'en'),
                         ('sitelink', 'enwiki'),
                         ('commonscat', None)],
        'Eiffelturm': [('label', 'de'), ('sitelink', 'dewiki')],
        'tour Eiffel': [('label', 'fr'), ('sitelink', 'frwiki')],
        'Tour Eiffel': [('alias', 'en')],
    }

    assert dict(names) == expect

def test_flatten_criteria():
    assert wikidata.flatten_criteria([]) == set()

def test_enwiki_url_to_title():
    start = 'https://en.wikipedia.org/wiki/'
    with pytest.raises(AssertionError):
        wikidata.enwiki_url_to_title('test')
    assert wikidata.enwiki_url_to_title(start + 'Example') == 'Example'
    assert wikidata.enwiki_url_to_title(start + 'A_B') == 'A B'
    assert wikidata.enwiki_url_to_title(start + 'A_%28B%29') == 'A (B)'

def test_wd_to_qid():
    with pytest.raises(AssertionError):

# Path: matcher/wikidata.py
# def get_query(q, south, north, west, east):
# def query_map(prefix, **kwargs):
# def bbox_query_map(south, north, west, east, **kwargs):
# def point_query_map(lat, lon, radius_m):
# def get_enwiki_query(*args):
# def get_enwiki_hq_query(*args):
# def get_item_tag_query(*args):
# def get_hq_item_tag_query(*args):
# def get_point_query(lat, lon, radius):
# def run_query(query, name=None, return_json=True, timeout=None, send_error_mail=False):
#     def error_mail(subject, r):
# def flatten_criteria(items):
# def wd_uri_to_id(value):
# def wd_to_qid(wd):
# def wd_uri_to_qid(value):
# def enwiki_url_to_title(url):
# def parse_enwiki_query(rows):
# def drop_tag_prefix(v):
# def parse_item_tag_query(rows, items):
# def page_banner_from_entity(entity, **kwargs):
# def entity_label(entity, language=None):
# def entity_description(entity, language=None):
# def names_from_entity(entity, skip_lang=None):
# def parse_osm_keys(rows):
# def get_location_hierarchy(qid, name=None):
# def up_one_level(qid, name=None):
# def next_level_types(types):
# def isa_list(types):
# def get_next_level_query(qid, entity, language='en', name=None):
# def next_level_places(qid, entity, language=None, query=None, name=None):
# def query_for_items(query, items):
# def get_item_labels(items):
# def row_qid_and_label(row, name):
# def get_isa(items, name=None):
# def item_types_graph(items, name=None, rows=None):
# def find_superclasses(items, name=None):
# def claim_value(claim):
# def country_iso_codes_from_qid(qid):
#     def __init__(self, qid, entity):
#     def retrieve_item(cls, qid):
#     def claims(self):
#     def labels(self):
#     def aliases(self):
#     def sitelinks(self):
#     def get_sitelinks(self):
#     def remove_badges(self):
#     def first_claim_value(self, key):
#     def has_coords(self):
#     def has_earth_coords(self):
#     def coords(self):
#     def nrhp(self):
#     def get_oql(self, criteria, radius):
#     def trim_location_from_names(self, wikidata_names):
#     def osm_key_query(self):
#     def osm_keys(self):
#     def languages_from_country(self):
#     def query_language_from_country(self):
#     def label(self, lang=None):
#     def names(self):
#     def is_a(self):
#     def is_a_detail(self):
#     def is_proposed(self):
#     def criteria(self):
#     def report_broken_wikidata_osm_tags(self):
#     def find_nrhp_match(self, overpass_reply):
#     def parse_item_query(self, criteria, overpass_reply):
# class WikidataItem:


# Path: tests/test_wikidata.py
from matcher import wikidata
import pytest
import vcr

    assert entity.label() == 'Natuurmuseum Brabant'

def test_names_from_entity():
    names = wikidata.names_from_entity(test_entity)

    expect = {
        'The Eiffel Tower': [('alias', 'en')],
        'Eiffel Tower': [('label', 'en'),
                         ('sitelink', 'enwiki'),
                         ('commonscat', None)],
        'Eiffelturm': [('label', 'de'), ('sitelink', 'dewiki')],
        'tour Eiffel': [('label', 'fr'), ('sitelink', 'frwiki')],
        'Tour Eiffel': [('alias', 'en')],
    }

    assert dict(names) == expect

def test_flatten_criteria():
    assert wikidata.flatten_criteria([]) == set()

def test_enwiki_url_to_title():
    start = 'https://en.wikipedia.org/wiki/'
    with pytest.raises(AssertionError):
        wikidata.enwiki_url_to_title('test')
    assert wikidata.enwiki_url_to_title(start + 'Example') == 'Example'
    assert wikidata.enwiki_url_to_title(start + 'A_B') == 'A B'
    assert wikidata.enwiki_url_to_title(start + 'A_%28B%29') == 'A (B)'

def test_wd_to_qid():
    with pytest.raises(AssertionError):

        wikidata.wd_to_qid({'type': 'uri', 'value': 'test'})