vervangt ini file met dotenv
continuous-integration/drone/push Build is failing

Maakt het makkelijker om te testen, en is sowieso betere manier denk ik
This commit is contained in:
2022-11-14 16:18:42 +01:00
parent da7262307d
commit 2c69b13f3d
7 changed files with 25 additions and 57 deletions
+3 -22
View File
@@ -1,9 +1,9 @@
import unittest
import configparser
import praw
import random
import requests
import json
import dotenv
import discord
from discord.ext import commands
@@ -12,32 +12,13 @@ import General
class TestGeneral(unittest.TestCase):
def setUp(self):
config = configparser.ConfigParser()
config.read('stroopwafel.ini')
self.tokens = config["tokens"]
self.r = praw.Reddit(
user_agent='StroopwafelBot',
client_secret=self.tokens["redditSecret"],
client_id=self.tokens["redditId"]
)
self.r.read_only = True
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)
bot.tokens = self.tokens
self.cog = General.General(bot)
def test_aww(self):
# Duplicate code is tijdelijk!!!11one
raww = self.r.subreddit('aww+catloaf+tuckedinkitties+babyelephantgifs+babybigcatgifs+blep+holdmynip+gingerkitty+cathighfive+catsstandingup+catsareassholes+eyebleach')
post = raww.top('month', limit=250)
listing = list(post)
random.shuffle(listing)
post = listing[0]
print(post)
self.assertIsInstance(post,praw.models.Submission)
def test_playlist(self):
data = self.cog.get_playlist_json()
with self.subTest(msg="Reddit doesn't return 200"):
@@ -45,4 +26,4 @@ class TestGeneral(unittest.TestCase):
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)
self.assertIsInstance(json.loads(data.content), dict)