from app.wikidata import WikidataSearch, WikidataOptions


def test_search_url_encoding():
    ws = WikidataSearch({"search": "Joe Biden"})
    assert ws.validateOptions() is True


def test_parse_search_results_filters_minimum_fields():
    ws = WikidataSearch({"search": "Joe Biden"})
    data = {
        "search": [
            {"url": "https://www.wikidata.org/wiki/Q6279", "id": "Q6279", "label": "Joe Biden", "description": "46th President"},
            {"id": "Q1", "label": "Bad"},
        ]
    }
    out = ws._parse_entities({"entities": {}}, resolve_properties=False)
    assert out == {"entities": []}

