import os import shutil from tests.utils import bot, OWNER, SENDER def setup_function(): shutil.copyfile("tests/datas/reviewstats.csv", "tests/reviews/reviewstats.csv") def test_hook_listen_anniv(bot): bot.test_public_message(bot.channel, SENDER, "!anniv") assert len(bot.answers) == 3 assert bot.answers[0].message.startswith("La revue") assert bot.answers[1].message.startswith("Hebdobot") assert bot.answers[2].message.startswith("L'April") def test_hook_bad_command(bot): bot.test_public_message(bot.channel, SENDER, "!aniv") assert len(bot.answers) == 1 assert bot.answers[0].message == f"{SENDER}, Yo !" def test_hook_date(bot): bot.test_public_message(bot.channel, SENDER, "!date") assert len(bot.answers) == 1 bot.test_public_message(bot.channel, SENDER, "!time") assert len(bot.answers) == 1 bot.test_public_message(bot.channel, SENDER, "!now") assert len(bot.answers) == 1 def test_hook_default(bot): bot.test_public_message(bot.channel, SENDER, "some message") assert bot.answers == [] def test_hook_hello(bot): bot.test_public_message(bot.channel, SENDER, "!salut") assert len(bot.answers) == 1 assert bot.answers[0].message == f"{SENDER}, bonjour \\o/" bot.test_public_message(bot.channel, SENDER, "!bonjour") assert len(bot.answers) == 1 assert bot.answers[0].message == f"{SENDER}, bonjour \\o/" bot.test_public_message(bot.channel, SENDER, "!hello") assert len(bot.answers) == 1 assert bot.answers[0].message == f"{SENDER}, bonjour \\o/" bot.test_public_message(bot.channel, SENDER, "bonjour hebdobot") assert len(bot.answers) == 1 assert bot.answers[0].message == f"{SENDER}, bonjour \\o/" def test_hook_help(bot): bot.test_public_message(bot.channel, SENDER, "!help") assert len(bot.answers) == 15 bot.test_public_message(bot.channel, SENDER, "!aide") assert len(bot.answers) == 15 def test_hook_license(bot): bot.test_public_message(bot.channel, SENDER, "!license") assert len(bot.answers) == 1 assert bot.answers[0].message.startswith("Hebdobot est un logiciel libre") bot.test_public_message(bot.channel, SENDER, "!licence") assert len(bot.answers) == 1 assert bot.answers[0].message.startswith("Hebdobot est un logiciel libre") def test_hook_listen_alexandrie(bot): bot.test_public_message(bot.channel, "alexandrie", "!version") assert bot.answers == [] bot.test_public_message(bot.channel, SENDER, "!version") assert bot.answers != [] def test_hook_record(bot): bot.test_public_message(bot.channel, SENDER, "!record") assert len(bot.answers) == 1 assert bot.answers[0].message.startswith("Le record de participation") def test_hook_stats(bot): bot.test_public_message(bot.channel, SENDER, "!stats") assert len(bot.answers) == 5 assert bot.answers[0].message.startswith("% Il y a eu ") def test_hook_stats_with_no_review(bot): os.remove("tests/reviews/reviewstats.csv") bot.test_public_message(bot.channel, SENDER, "!stats") assert len(bot.answers) == 5 assert bot.answers[0].message == "% Il n'y a pas encore eu de revue." def test_hook_status(bot): bot.test_public_message(bot.channel, SENDER, "!status") assert len(bot.answers) == 3 assert bot.answers[0].message.startswith(f"{SENDER}, voici l'état") bot.test_public_message(bot.channel, SENDER, "!statut") assert len(bot.answers) == 3 assert bot.answers[0].message.startswith(f"{SENDER}, voici l'état") assert bot.answers[1].message == f" revue en cours : {bot.review.started}" assert bot.answers[2].message == " animateur revue : none" def test_hook_status_started_review(bot): bot.test_public_message(bot.channel, OWNER, "!start") bot.test_public_message(bot.channel, SENDER, "!statut") assert len(bot.answers) == 3 assert bot.answers[0].message.startswith(f"{SENDER}, voici l'état") assert bot.answers[1].message == f" revue en cours : {bot.review is not None}" assert bot.answers[2].message == f" animateur revue : {OWNER}" def test_hook_thanks(bot): bot.test_public_message(bot.channel, SENDER, "!merci") assert len(bot.answers) == 1 assert bot.answers[0].message == f"{SENDER}, de rien \\o/" def test_hook_version(bot): bot.test_public_message(bot.channel, SENDER, "!version") assert len(bot.answers) == 1