def test_load_emoji_data(): my_emoji = emoji.Emoji("tests/test_emoji.csv") assert len(my_emoji.emoji_dict[-3]) == 4 assert len(my_emoji.emoji_dict[-2]) == 6 assert len(my_emoji.emoji_dict[0]) == 1 assert len(my_emoji.emoji_dict[1]) == 2 assert len(my_emoji.emoji_dict[2]) == 3 assert len(my_emoji.emoji_dict[3]) == 4 assert "1F632" in my_emoji.emoji_dict[-3] assert "1F644" in my_emoji.emoji_dict[-2] assert "1F636" in my_emoji.emoji_dict[0] assert "1F610" in my_emoji.emoji_dict[1] assert "1F600" in my_emoji.emoji_dict[2] assert "1F601" in my_emoji.emoji_dict[3]
def generate_headline(selected_match): """ generates the actual headline match is the match used to generate the headline returns a string representing the headline """ my_emoji = emoji.Emoji() str_headline_champions = " {} are champions! {} beat {} ({}-{}){} {}" str_headline_victory = " {} {} {} ({}-{}){} {}" str_headline_draw = " {} {} {} ({}-{}) {}" str_headline_body = "" str_nt_details = "" if selected_match: # now generate the headline str_nt_details = generate_extra_time_headline(selected_match) excitement_index = selected_match.excitement_index selected_emoji = my_emoji.generate_emoji(excitement_index) if excitement_index == 4: # champions str_headline_body = str_headline_champions.format( config.MY_TEAM, config.MY_TEAM, selected_match.opponent, selected_match.score[0], selected_match.score[1], str_nt_details, selected_emoji) elif excitement_index >= 2: # win str_headline_body = str_headline_victory.format( config.MY_TEAM, "beat", selected_match.opponent, selected_match.score[0], selected_match.score[1], str_nt_details, selected_emoji) elif excitement_index < 0: # loss str_headline_body = str_headline_victory.format( config.MY_TEAM, "lost to", selected_match.opponent, selected_match.score[0], selected_match.score[1], str_nt_details, selected_emoji) else: # draw str_headline_body = str_headline_draw.format( config.MY_TEAM, "drew with", selected_match.opponent, selected_match.score[0], selected_match.score[1], selected_emoji) else: return NO_MATCH_HEADLINE return config.EMOJI_PREFIX + format_intro_headline( selected_match) + str_headline_body + get_otd_suffix()
def test_empty_emoji_dict(): my_emoji = emoji.Emoji("tests/test_emoji.csv") assert my_emoji.emoji_dict is not None my_emoji.empty_emoji_dict() assert len(my_emoji.emoji_dict) == len(emoji.EXCITEMENT_INDEX) assert my_emoji.emoji_dict[0] == []
def test_get_random_emoji_withdata(): my_emoji = emoji.Emoji("tests/test_emoji.csv") assert my_emoji.get_random_emoji(0) == "1F636"
def test_get_random_emoji_invalidindex(): my_emoji = emoji.Emoji("tests/test_emoji.csv") assert my_emoji.get_random_emoji(5) == ""