# Path: matcher/browse.py
# def place_from_qid(qid, q=None, entity=None):
# def hit_from_qid(qid, q=None, entity=None):
# def qid_to_search_string(qid, entity):
# def place_from_nominatim(hit):
# def get_details(item_id, timing=None, lang=None, sort=None):
# 
# 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: matcher/nominatim.py
# class SearchError(Exception):
# def lookup_with_params(**kwargs):
# def lookup(q):
# def get_us_county(county, state):
#     def pred(hit):
# def get_us_city(name, state):
# def reverse(osm_type, osm_id, polygon_text=1):


from matcher import browse, wikidata, nominatim
from collections import OrderedDict
        'claims': {
            'P31': [{'mainsnak': {'datavalue': {'value': {'id': 'Q6256'}}}}]
        },
    }
    assert browse.qid_to_search_string('Q30', entity) == label

def test_qid_to_search_string(monkeypatch):
    qid = 'Q984466'
    entity = {
        'labels': {'en': {'value': 'Murray Hill'}},
    }

    def full_name_dict(qid):
        return {
            'name': 'Murray Hill',
            'up': 'Union County',
            'country_qid': 'Q30',
            'country_name': 'United States of America',
            'up_country_qid': 'Q30',
            'up_country_name': 'United States of America'
        }

    monkeypatch.setattr(wikidata, 'up_one_level', full_name_dict)
    q = browse.qid_to_search_string(qid, entity)

    assert q == 'Murray Hill, Union County, United States of America'

    def empty_name_dict(qid):
        return {}


# Path: matcher/browse.py
# def place_from_qid(qid, q=None, entity=None):
# def hit_from_qid(qid, q=None, entity=None):
# def qid_to_search_string(qid, entity):
# def place_from_nominatim(hit):
# def get_details(item_id, timing=None, lang=None, sort=None):
# 
# 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: matcher/nominatim.py
# class SearchError(Exception):
# def lookup_with_params(**kwargs):
# def lookup(q):
# def get_us_county(county, state):
#     def pred(hit):
# def get_us_city(name, state):
# def reverse(osm_type, osm_id, polygon_text=1):


# Path: tests/test_browse.py
from matcher import browse, wikidata, nominatim
from collections import OrderedDict

        'claims': {
            'P31': [{'mainsnak': {'datavalue': {'value': {'id': 'Q6256'}}}}]
        },
    }
    assert browse.qid_to_search_string('Q30', entity) == label

def test_qid_to_search_string(monkeypatch):
    qid = 'Q984466'
    entity = {
        'labels': {'en': {'value': 'Murray Hill'}},
    }

    def full_name_dict(qid):
        return {
            'name': 'Murray Hill',
            'up': 'Union County',
            'country_qid': 'Q30',
            'country_name': 'United States of America',
            'up_country_qid': 'Q30',
            'up_country_name': 'United States of America'
        }

    monkeypatch.setattr(wikidata, 'up_one_level', full_name_dict)
    q = browse.qid_to_search_string(qid, entity)

    assert q == 'Murray Hill, Union County, United States of America'

    def empty_name_dict(qid):
        return {}


    monkeypatch.setattr(wikidata, 'up_one_level', empty_name_dict)