def test_find_channel_match_fuzzy_match(): fuzzy_matching_channel = mocked_channel(name="matching-GeneRal-channel") other_channel = mocked_channel(name="non-matched channel") matched_channel = SimpleAsyncDiscord.find_channel_that_matches("general", [fuzzy_matching_channel, other_channel]) assert_that(matched_channel, is_(fuzzy_matching_channel))
def test_find_channel_match_exact_match(): exact_matching_channel = mocked_channel(name="general") other_channel = mocked_channel(name="General") matched_channel = SimpleAsyncDiscord.find_channel_that_matches("general", [exact_matching_channel, other_channel]) assert_that(matched_channel, is_(exact_matching_channel))
def test_find_channel_match_case_insensitive_match(): case_insensitive_matching_channel = mocked_channel(name="GeNeRaL") other_channel = mocked_channel(name="non-matched General") matched_channel = SimpleAsyncDiscord.find_channel_that_matches("general", [case_insensitive_matching_channel, other_channel]) assert_that(matched_channel, is_(case_insensitive_matching_channel))
def test_find_channel_match_more_than_one_channel_found_and_player_informed(): sending_player = fake_player(steam_id=1, name="Player") matched_channel = SimpleAsyncDiscord.find_channel_that_matches("general", [mocked_channel(name="matched_general"), mocked_channel(name="another-matched-general")], sending_player) verify(sending_player).tell("Found ^62^7 matching discord channels for #general:") verify(sending_player).tell("#matched_general #another-matched-general ") assert_that(matched_channel, is_(None))
def test_find_channel_match_more_than_one_channel_found(): matched_channel = SimpleAsyncDiscord.find_channel_that_matches("general", [mocked_channel(name="matched_general"), mocked_channel(name="another-matched-general")]) assert_that(matched_channel, is_(None))
def test_find_channel_match_no_match_found(): matched_channel = SimpleAsyncDiscord.find_channel_that_matches("general", [mocked_channel(name="no_match-channel"), mocked_channel(name="non-matched channel")]) assert_that(matched_channel, is_(None))