import unittest import dotenv import os import discord import requests from discord.ext import commands import Shitpost class TestShitpost(unittest.TestCase): def setUp(self): dotenv.load_dotenv() intents = discord.Intents.default() intents.message_content = True intents.members = True bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'), description='Stroopwafel. Shitpost bot extraordinaire.', pm_help=True, intents=intents) self.cog = Shitpost.Shitpost(bot) def test_review(self): TOPIC = "qpwoeirut12" topic_review = self.cog.get_review_string(TOPIC) with self.subTest(msg=f"Topic review does not return a string"): self.assertIsInstance(topic_review, str) with self.subTest(msg=f"Topic review does not contain the topic"): self.assertIn(TOPIC, topic_review) basic_review = self.cog.get_review_string() with self.subTest(msg=f"Review does not return a string"): self.assertIsInstance(basic_review, str) def test_watspelenwe_sass(self): once = self.cog.get_watspelenwe_sass() twice = self.cog.get_watspelenwe_sass() with self.subTest(msg="Watspelenwe does not seed correctly"): self.assertEqual(once, twice) with self.subTest(msg="Watspelenwe does not return a string"): self.assertIsInstance(once, str) def test_watspelenwe_cal(self): data = requests.get(os.getenv('STROOP_CALDAV_CAL')) if not data: self.skipTest(f"Server at {self.cog.muzak_url} has an error, or is unavailable") (activiteit, reden) = self.cog.get_watspelenwe_cal() with self.subTest(msg="Watspelenwe activiteit does not return a string"): self.assertIsInstance(activiteit, str) with self.subTest(msg="Watspelenwe reden does not return a string"): self.assertIsInstance(reden, str)