refactors en echte tests ofzo

This commit is contained in:
2022-11-04 23:25:36 +01:00
parent 3c8d34acdd
commit f89889fc48
2 changed files with 26 additions and 13 deletions
+18 -7
View File
@@ -2,15 +2,14 @@ import unittest
import configparser
import praw
import random
import requests
import json
import discord
from discord.ext import commands
import General
class TestTest(unittest.TestCase):
def test_a(self):
self.assertEqual(1, 1)
def test_b(self):
self.assertEqual("ab", "a" + "b")
class TestGeneral(unittest.TestCase):
def setUp(self):
config = configparser.ConfigParser()
@@ -22,6 +21,12 @@ class TestGeneral(unittest.TestCase):
client_id=self.tokens["redditId"]
)
self.r.read_only = True
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)
bot.tokens = self.tokens
self.cog = General.General(bot)
def test_aww(self):
# Duplicate code is tijdelijk!!!11one
@@ -34,4 +39,10 @@ class TestGeneral(unittest.TestCase):
self.assertIsInstance(post,praw.models.Submission)
def test_playlist(self):
pass
data = self.cog.get_playlist_json()
with self.subTest(msg="Reddit doesn't return 200"):
self.assertEqual(data.status_code, 200)
with self.subTest(msg="Not a good response"):
self.assertIsInstance(data, requests.Response)
with self.subTest(msg="Does not convert to json"):
self.assertIsInstance(json.loads(data.content), dict)