Skip to content

Commit

Permalink
Crude !!/hats test
Browse files Browse the repository at this point in the history
  • Loading branch information
quartata committed Dec 5, 2017
1 parent 39b1558 commit 8f20c74
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion chatcommands.py
Expand Up @@ -458,7 +458,7 @@ def hats():
daystr = "days" if diff.days != 1 else "day"
hourstr = "hours" if hours != 1 else "hour"
minutestr = "minutes" if minutes != 1 else "minute"
secondstr = "seconds" if seconds != 1 else "diff_second"
secondstr = "seconds" if seconds != 1 else "second"
return_string = "WE LOVE HATS! Winter Bash will begin in {} {}, {} {}, {} {}, and {} {}.".format(
diff.days, daystr, hours, hourstr, minutes, minutestr, seconds, secondstr)
elif wb_end > now:
Expand Down
2 changes: 1 addition & 1 deletion chatcommunicate.py
Expand Up @@ -337,7 +337,7 @@ def dispatch_command(msg):
command_name = cmd[3:].lower()

quiet_action = command_name[-1] == "-"
command_name = regex.sub(r"\W*$", "", command_name)
command_name = regex.sub(r"[[:punct:]]*$", "", command_name)

if command_name not in _commands["prefix"]:
return "No such command '{}'.".format(command_name)
Expand Down
12 changes: 12 additions & 0 deletions test/test_chatcommands.py
Expand Up @@ -4,6 +4,7 @@
from classes._Post import Post
from globalvars import GlobalVars

import datetime
import os
import pytest
import regex
Expand Down Expand Up @@ -49,6 +50,17 @@ def test_location():
assert chatcommands.location() == GlobalVars.location


@patch("chatcommands.datetime")
def test_hats(date):
date.side_effect = datetime.datetime

date.utcnow.return_value = datetime.datetime(2017, 12, 12, hour=23)
assert chatcommands.hats() == "WE LOVE HATS! Winter Bash will begin in 0 days, 1 hour, 0 minutes, and 0 seconds."

date.utcnow.return_value = datetime.datetime(2018, 1, 8, hour=23)
assert chatcommands.hats() == "Winter Bash won't end for 0 days, 1 hour, 0 minutes, and 0 seconds. GO EARN SOME HATS!"


def test_blame():
msg1 = Fake({
"_client": {
Expand Down

0 comments on commit 8f20c74

Please sign in to comment.