Testing/CI #21
+16
-17
@@ -10,6 +10,7 @@ import sys
|
||||
import os
|
||||
import random
|
||||
import caldav
|
||||
import warnings
|
||||
|
||||
class Shitpost(commands.Cog):
|
||||
"""Schijtpaal commando's. Alleen bruikbaar in de daarvoor toegewezen schijtpaal kanalen."""
|
||||
@@ -28,6 +29,7 @@ class Shitpost(commands.Cog):
|
||||
'clownsfiguur','krotenkoker','hansworst','grappenmaker','flapdrol','oen',
|
||||
'achterlijk gebakje','demente dibbes','geitenbreier','koekwous','sufkop']
|
||||
self.caldav_client = caldav.DAVClient(url=os.getenv('STROOP_CALDAV_HOST'))
|
||||
warnings.simplefilter("ignore")
|
||||
|
||||
def __check(self, ctx): #Todo: Is dit het shitpost kanaal?
|
||||
return True
|
||||
@@ -708,7 +710,7 @@ class Shitpost(commands.Cog):
|
||||
yield from ctx.channel.send(member.mention+ ", " + ctx.author.mention + " vindt jou een " + random.choice(self.insult) + "! :angry:")
|
||||
yield from ctx.message.delete()
|
||||
|
||||
def watspelenweecht(self):
|
||||
def get_watspelenwe_cal(self):
|
||||
"""Geeft een paar terug, met de titel en omschrijving van het eerstvolgende event uit de kalender"""
|
||||
calendar = self.caldav_client.calendar(url=os.getenv('STROOP_CALDAV_CAL')) # refresh kalender
|
||||
|
||||
@@ -720,14 +722,7 @@ class Shitpost(commands.Cog):
|
||||
)
|
||||
return (events[0].vobject_instance.vevent.summary.value, events[0].vobject_instance.vevent.description.value)
|
||||
|
||||
|
||||
@commands.command(pass_context=True)
|
||||
@asyncio.coroutine
|
||||
def watspelenwe(self, ctx):
|
||||
"""Stroop weet wat we spelen op vrijdag.
|
||||
Geeft elke week een pseudo-random antwoord.
|
||||
Geseed op weeknummer + jaar.
|
||||
"""
|
||||
def get_watspelenwe_sass(self):
|
||||
SASS = [
|
||||
"Pathfinder. Nee lmao wie speelt er nu nog pathfinder?",
|
||||
"Midfloat. Oh wacht dat is? Oh in Apeldoorn zeg je? Jeetje.",
|
||||
@@ -850,8 +845,19 @@ class Shitpost(commands.Cog):
|
||||
else:
|
||||
message = "We spelen " + DAG + random.choice(SPELLEN) + " " + random.choice(PLAATSEN) + ", aanvang " + random.choice(AANVANG)
|
||||
|
||||
return message
|
||||
|
||||
@commands.command(pass_context=True)
|
||||
@asyncio.coroutine
|
||||
def watspelenwe(self, ctx):
|
||||
"""Stroop weet wat we spelen op vrijdag.
|
||||
Geeft elke week een pseudo-random antwoord.
|
||||
Geseed op weeknummer + jaar.
|
||||
"""
|
||||
message = self.get_watspelenwe_sass()
|
||||
|
||||
try:
|
||||
(activiteit, reden) = self.watspelenweecht()
|
||||
(activiteit, reden) = self.get_watspelenwe_cal()
|
||||
message += f"\nNee, we doen eigenlijk {activiteit} want {reden}"
|
||||
except:
|
||||
message += ". En wilt iemand even aan Mark vragen of hij de kalender bijhoudt?"
|
||||
@@ -919,10 +925,3 @@ class Shitpost(commands.Cog):
|
||||
topic = " ".join(args)
|
||||
message = self.get_review_string(topic)
|
||||
yield from ctx.channel.send(message)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Shitpost(bot))
|
||||
|
||||
+22
-1
@@ -1,6 +1,8 @@
|
||||
import unittest
|
||||
import dotenv
|
||||
import os
|
||||
import discord
|
||||
import requests
|
||||
from discord.ext import commands
|
||||
|
||||
import Shitpost
|
||||
@@ -24,4 +26,23 @@ class TestShitpost(unittest.TestCase):
|
||||
|
||||
basic_review = self.cog.get_review_string()
|
||||
with self.subTest(msg=f"Review does not return a string"):
|
||||
self.assertIsInstance(basic_review, str)
|
||||
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)
|
||||
Reference in New Issue
Block a user