refactors en echte tests ofzo
This commit is contained in:
+7
-5
@@ -8,7 +8,6 @@ import json, requests
|
|||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from sympy import latex, symbols, preview, Symbol #for LaTeX images
|
from sympy import latex, symbols, preview, Symbol #for LaTeX images
|
||||||
import youtube_dl
|
import youtube_dl
|
||||||
import ffmpeg
|
|
||||||
|
|
||||||
class General(commands.Cog):
|
class General(commands.Cog):
|
||||||
"""Overal toegestaan."""
|
"""Overal toegestaan."""
|
||||||
@@ -16,6 +15,7 @@ class General(commands.Cog):
|
|||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.voice_states = {}
|
self.voice_states = {}
|
||||||
|
self.muzak_url = 'https://hdcon-muzak.herokuapp.com'
|
||||||
self.r = praw.Reddit(
|
self.r = praw.Reddit(
|
||||||
user_agent='StroopwafelBot',
|
user_agent='StroopwafelBot',
|
||||||
client_secret=self.bot.tokens["redditSecret"],
|
client_secret=self.bot.tokens["redditSecret"],
|
||||||
@@ -121,15 +121,17 @@ Op <https://gifrun.com/> kunt u bijvoorbeeld via een web-interface gifjes maken
|
|||||||
|
|
||||||
Namens de directie van Stroopwafel B.V. onze excuses voor dit ongemak.""")
|
Namens de directie van Stroopwafel B.V. onze excuses voor dit ongemak.""")
|
||||||
|
|
||||||
|
def get_playlist_json(self):
|
||||||
|
return requests.get(self.muzak_url + '/stroopwafel')
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def playlist(self, ctx):
|
def playlist(self, ctx):
|
||||||
"""HDcon2021 playlist"""
|
"""HDcon2021 playlist"""
|
||||||
muzak_url = 'https://hdcon-muzak.herokuapp.com'
|
data = json.loads(self.get_playlist_json().content)
|
||||||
data = json.loads(requests.get(muzak_url + '/stroopwafel').content) # als dit faalt yolo no catch
|
msg = 'Stemmen en nomineren kan hier: {}\n'.format(self.muzak_url)
|
||||||
msg = 'Stemmen en nomineren kan hier: {}\n'.format(muzak_url)
|
|
||||||
msg += '*Er zijn al {} nummers genomineerd*\n'.format(data['stemCount'])
|
msg += '*Er zijn al {} nummers genomineerd*\n'.format(data['stemCount'])
|
||||||
yield from ctx.channel.send(msg)
|
yield from ctx.channel.send(self.get_playlist_msg())
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=True)
|
@commands.command(pass_context=True, hidden=True)
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
|||||||
@@ -2,15 +2,14 @@ import unittest
|
|||||||
import configparser
|
import configparser
|
||||||
import praw
|
import praw
|
||||||
import random
|
import random
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
import General
|
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):
|
class TestGeneral(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
@@ -22,6 +21,12 @@ class TestGeneral(unittest.TestCase):
|
|||||||
client_id=self.tokens["redditId"]
|
client_id=self.tokens["redditId"]
|
||||||
)
|
)
|
||||||
self.r.read_only = True
|
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):
|
def test_aww(self):
|
||||||
# Duplicate code is tijdelijk!!!11one
|
# Duplicate code is tijdelijk!!!11one
|
||||||
@@ -34,4 +39,10 @@ class TestGeneral(unittest.TestCase):
|
|||||||
self.assertIsInstance(post,praw.models.Submission)
|
self.assertIsInstance(post,praw.models.Submission)
|
||||||
|
|
||||||
def test_playlist(self):
|
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)
|
||||||
Reference in New Issue
Block a user