Tests corona
Beetje slappe test wel, maar je moet iets.
This commit is contained in:
+15
-35
@@ -131,26 +131,20 @@ class Shitpost(commands.Cog):
|
|||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
yield from ctx.channel.send(ctx.author.mention + ' ' + str(message))
|
yield from ctx.channel.send(ctx.author.mention + ' ' + str(message))
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=False)
|
def get_corona_message(self):
|
||||||
@asyncio.coroutine
|
response = requests.get('https://covid.ourworldindata.org/data/latest/owid-covid-latest.json')
|
||||||
def coronaold(self, ctx):
|
if response:
|
||||||
try:
|
answer = json.loads(response.content.decode('utf-8'))
|
||||||
yield from ctx.message.delete()
|
d = answer["NLD"]
|
||||||
except:
|
message = f"Dit is mijn informatie van **{d['last_updated_date']}**: \n\n"
|
||||||
print("No permission to delete message")
|
message += f"Er zijn in Nederland {d['total_cases']:.0f} bevestigde gevallen 😷"
|
||||||
params = (
|
message += f" dat is 🔺{d['new_cases']:.0f}🔺 meer dan de dag er voor! \n"
|
||||||
('minimal/', 'true'),
|
message += f"Er zijn ondertussen {d['total_deaths']:.0f} mensen dood 💀"
|
||||||
('format/', 'json')
|
message += f" waarvan {d['new_deaths']:.0f} ☠️ in de meest recente 24 uur. \n"
|
||||||
)
|
message += f"En het r-getal is {d['reproduction_rate']}!\n\n"
|
||||||
response = requests.get('https://corona-stats.online/NL/?format=json&source=2')
|
message += "*Data van https://ourworldindata.org/coronavirus*"
|
||||||
answer = json.loads(response.content.decode('utf-8'))
|
return message
|
||||||
answer = answer["data"]
|
return None
|
||||||
message = "Er zijn in Nederland " + str(answer[0]["cases"]) + " bevestigde gevallen 😷"
|
|
||||||
message += " dat is 🔺" + str(answer[0]["todayCases"]) + "🔺 meer dan gisteren! "
|
|
||||||
message += "Er zijn ondertussen " + str(answer[0]["deaths"]) + " mensen dood 💀"
|
|
||||||
message += " waarvan " + str(answer[0]["todayDeaths"]) + " ☠️ in de afgelopen 24 uur. "
|
|
||||||
message += "Ook liggen er " + str(answer[0]["critical"]) + " mensen op de IC 🏥"
|
|
||||||
yield from ctx.channel.send(ctx.author.mention + ' ' + str(message))
|
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=False)
|
@commands.command(pass_context=True, hidden=False)
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
@@ -159,21 +153,7 @@ class Shitpost(commands.Cog):
|
|||||||
yield from ctx.message.delete()
|
yield from ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
params = (
|
message = self.get_corona_message()
|
||||||
('minimal/', 'true'),
|
|
||||||
('format/', 'json')
|
|
||||||
)
|
|
||||||
response = requests.get('https://covid.ourworldindata.org/data/latest/owid-covid-latest.json')
|
|
||||||
answer = json.loads(response.content.decode('utf-8'))
|
|
||||||
d = answer["NLD"]
|
|
||||||
message = f"Dit is mijn informatie van **{d['last_updated_date']}**: \n\n"
|
|
||||||
message += f"Er zijn in Nederland {d['total_cases']:.0f} bevestigde gevallen 😷"
|
|
||||||
message += f" dat is 🔺{d['new_cases']:.0f}🔺 meer dan de dag er voor! \n"
|
|
||||||
message += f"Er zijn ondertussen {d['total_deaths']:.0f} mensen dood 💀"
|
|
||||||
message += f" waarvan {d['new_deaths']:.0f} ☠️ in de meest recente 24 uur. \n"
|
|
||||||
message += f"Er zijn ondertussen {d['people_vaccinated']:.0f} mensen gevaccineerd! 💉 "
|
|
||||||
message += f"En het r-getal is {d['reproduction_rate']}!\n\n"
|
|
||||||
message += "*Data van https://ourworldindata.org/coronavirus*"
|
|
||||||
yield from ctx.channel.send(ctx.author.mention + ' ' + str(message))
|
yield from ctx.channel.send(ctx.author.mention + ' ' + str(message))
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=False)
|
@commands.command(pass_context=True, hidden=False)
|
||||||
|
|||||||
+5
-1
@@ -158,4 +158,8 @@ class TestShitpost(unittest.TestCase):
|
|||||||
self.assertIn(".jpg", inspo)
|
self.assertIn(".jpg", inspo)
|
||||||
|
|
||||||
def test_giethetaloan(self):
|
def test_giethetaloan(self):
|
||||||
self.assertIn("nee", self.cog.get_giet_het_oan().lower())
|
self.assertIn("nee", self.cog.get_giet_het_oan().lower())
|
||||||
|
|
||||||
|
def test_corona(self):
|
||||||
|
message = self.cog.get_corona_message()
|
||||||
|
self.assertIsInstance(message, str)
|
||||||
|
|||||||
Reference in New Issue
Block a user