def test_do_not_choke_on_unicode() -> None:
    s = '①②④⑧⇅⊕█↑▪🐞🚫🏆⏩⏪︎📰💻▾'
    # As a whole…
    result = command.results_from_queries([s])[0][0]
    assert not result.has_match()
    # …and for each char individually.
    for result, _, _ in command.results_from_queries(list(s)):
        assert not result.has_match()
def test_results_from_queries() -> None:
    result = command.results_from_queries(['bolt'])[0][0]
    assert result.has_match()
    assert not result.is_ambiguous()
    assert result.get_best_match() == 'Lightning Bolt'
    result = command.results_from_queries(['Far/Away'])[0][0]
    assert result.has_match()
    assert not result.is_ambiguous()
    assert result.get_best_match() == 'Far // Away'
    result = command.results_from_queries(['Jötun Grunt'])[0][0]
    assert result.has_match()
    assert not result.is_ambiguous()
    assert result.get_best_match() == 'Jötun Grunt'
    result = command.results_from_queries(['Jotun Grunt'])[0][0]
    assert result.has_match()
    assert not result.is_ambiguous()
    assert result.get_best_match() == 'Jötun Grunt'
    result = command.results_from_queries(['Ready / Willing'])[0][0]
    assert result.has_match()
    assert not result.is_ambiguous()
    assert result.get_best_match() == 'Ready // Willing'
    result = command.results_from_queries(['Fire // Ice'])[0][0]
    assert result.has_match()
    assert not result.is_ambiguous()
    assert result.get_best_match() == 'Fire // Ice'
    result = command.results_from_queries(['Upheaval'])[0][0]
    assert result.has_match()
    assert not result.is_ambiguous()
    assert result.get_best_match() == 'Upheaval'
    result = command.results_from_queries(['Llanowar Elves|7ED'])[0][0]
    assert result.has_match()
    assert not result.is_ambiguous()
    assert result.get_best_match() == 'Llanowar Elves'
Esempio n. 3
0
def test_solo_query():
    names = command.parse_queries('[Gilder Bairn]')
    assert len(names) == 1
    assert names[0] == 'gilder bairn'
    results = command.results_from_queries(names,
                                           whoosh_search.WhooshSearcher())[0]
    assert len(results) == 1
Esempio n. 4
0
def test_split_cards() -> None:
    cards = oracle.load_cards(['Armed // Dangerous'])
    assert len(cards) == 1
    assert image_fetcher.download_image(cards) is not None
    names = command.parse_queries('[Toil // Trouble]', False)
    assert len(names) == 1
    results = command.results_from_queries(names)
    assert len(results) == 1
Esempio n. 5
0
def test_results_from_queries():
    searcher = whoosh_search.WhooshSearcher()
    result = command.results_from_queries(['bolt'], searcher)[0]
    assert result.has_match()
    assert not result.is_ambiguous()
    assert result.get_best_match() == 'Lightning Bolt'
    result = command.results_from_queries(['Far/Away'], searcher)[0]
    assert result.has_match()
    assert not result.is_ambiguous()
    assert result.get_best_match() == 'Far // Away'
    result = command.results_from_queries(['Jötun Grunt'], searcher)[0]
    assert result.has_match()
    assert not result.is_ambiguous()
    assert result.get_best_match() == 'Jötun Grunt'
    result = command.results_from_queries(['Jotun Grunt'], searcher)[0]
    assert result.has_match()
    assert not result.is_ambiguous()
    assert result.get_best_match() == 'Jötun Grunt'
    result = command.results_from_queries(['Ready / Willing'], searcher)[0]
    assert result.has_match()
    assert not result.is_ambiguous()
    assert result.get_best_match() == 'Ready // Willing'
    result = command.results_from_queries(['Fire // Ice'], searcher)[0]
    assert result.has_match()
    assert not result.is_ambiguous()
    assert result.get_best_match() == 'Fire // Ice'
    result = command.results_from_queries(['Upheaval'], searcher)[0]
    assert result.has_match()
    assert not result.is_ambiguous()
    assert result.get_best_match() == 'Upheaval'
Esempio n. 6
0
def test_split_cards():
    cards = oracle.load_cards(['Armed // Dangerous'])
    assert len(cards) == 1
    assert image_fetcher.download_image(cards) is not None
    names = command.parse_queries('[Toil // Trouble]')
    assert len(names) == 1
    results = command.results_from_queries(names,
                                           whoosh_search.WhooshSearcher())[0]
    assert len(results) == 1
Esempio n. 7
0
 async def convert(cls, ctx: Context, argument: str) -> Optional[Card]:
     try:
         result, mode, printing = command.results_from_queries([argument])[0]
         if result.has_match() and not result.is_ambiguous():
             return command.cards_from_names_with_mode([result.get_best_match()], mode, printing)[0]
         if result.is_ambiguous():
             message = await ctx.send('{author}: Ambiguous name for {c}. Suggestions: {s}'.format(author=ctx.author.mention, c=ctx.command, s=command.disambiguation(result.get_ambiguous_matches()[0:5])))
             await command.disambiguation_reactions(message, result.get_ambiguous_matches()[0:5])
         else:
             await ctx.send('{author}: No matches.'.format(author=ctx.author.mention))
         return None
     except Exception as exc:
         raise BadArgument('Could not find card') from exc
Esempio n. 8
0
def test_partial_query() -> None:
    names = command.parse_queries("[Ertai's]", False)
    assert len(names) == 1
    results = command.results_from_queries(names)[0][0]
    assert len(results.get_ambiguous_matches()) == 3
Esempio n. 9
0
def test_legend_query() -> None:
    names = command.parse_queries('[Ertai]', False)
    assert len(names) == 1
    results = command.results_from_queries(names)[0][0]
    assert len(results.get_ambiguous_matches()) == 2
Esempio n. 10
0
def test_double_query() -> None:
    names = command.parse_queries('[Mother of Runes] [Ghostfire]', False)
    assert len(names) == 2
    results = command.results_from_queries(names)
    assert len(results) == 2
Esempio n. 11
0
def test_solo_query() -> None:
    names = command.parse_queries('[Gilder Bairn]', False)
    assert len(names) == 1
    assert names[0] == 'gilder bairn'
    results = command.results_from_queries(names)
    assert len(results) == 1
Esempio n. 12
0
def test_partial_query():
    names = command.parse_queries("[Kamahl's]")
    assert len(names) == 1
    results = command.results_from_queries(names,
                                           whoosh_search.WhooshSearcher())[0]
    assert len(results.get_ambiguous_matches()) == 3
Esempio n. 13
0
def test_legend_query():
    names = command.parse_queries('[Kamahl]')
    assert len(names) == 1
    results = command.results_from_queries(names,
                                           whoosh_search.WhooshSearcher())[0]
    assert len(results.get_ambiguous_matches()) == 2
Esempio n. 14
0
def test_double_query():
    names = command.parse_queries('[Mother of Runes] [Ghostfire]')
    assert len(names) == 2
    results = command.results_from_queries(names,
                                           whoosh_search.WhooshSearcher())
    assert len(results) == 2