<commit_before>import datetime

from takeyourmeds.utils.test import TestCase

class SmokeTest(TestCase):
    def test_create(self):
        self.assertGET(200, 'reminders:create', login=True)

class DeleteTests(TestCase):
    def test_GET(self):
        instance = self.user.reminders.create()
        self.assertGET(405, 'reminders:delete', instance.pk, login=True)

    def test_POST(self):
        instance = self.user.reminders.create()
        self.assert_(self.user.reminders.exists())
        response = self.assertPOST(
            302, {}, 'reminders:delete', instance.pk, login=True
        )
        self.assertRedirectsTo(response, 'dashboard:view')
        self.failIf(self.user.reminders.exists())

    def test_forbidden(self):
        """
        Users cannot delete other user's reminders.
        """

        other = self.create_user('other')
        instance = self.user.reminders.create()

        self.assertPOST(
            404,
            {},
            'reminders:delete',
            instance.pk,
            login=True,
            user=other,
        )

        self.assert_(self.user.reminders.exists())

class TestCron(TestCase):
    def test_cron(self):
        ten_min_ago = datetime.datetime.utcnow() - \
            datetime.timedelta(minutes=10)

        reminder = self.user.reminders.create(
            message="test",
            phone_number='123',
        )

        reminder.times.create(
            time='10:00',
            last_run=ten_min_ago,
        )

class TriggerTest(TestCase):
    def test_trigger_now(self):
        instance = self.user.reminders.create()

        response = self.assertPOST(
            302,
            {},
            'reminders:trigger', instance.pk,
            login=True,
        )

        self.assertRedirectsTo(response, 'dashboard:view')<commit_msg>Rename to 'reminder'<commit_after>import datetime

from takeyourmeds.utils.test import TestCase

class SmokeTest(TestCase):
    def test_create(self):
        self.assertGET(200, 'reminders:create', login=True)

class DeleteTests(TestCase):
    def test_GET(self):
        instance = self.user.reminders.create()
        self.assertGET(405, 'reminders:delete', instance.pk, login=True)

    def test_POST(self):
        instance = self.user.reminders.create()
        self.assert_(self.user.reminders.exists())
        response = self.assertPOST(
            302, {}, 'reminders:delete', instance.pk, login=True
        )
        self.assertRedirectsTo(response, 'dashboard:view')
        self.failIf(self.user.reminders.exists())

    def test_forbidden(self):
        """
        Users cannot delete other user's reminders.
        """

        other = self.create_user('other')
        instance = self.user.reminders.create()

        self.assertPOST(
            404,
            {},
            'reminders:delete',
            instance.pk,
            login=True,
            user=other,
        )

        self.assert_(self.user.reminders.exists())

class TestCron(TestCase):
    def test_cron(self):
        ten_min_ago = datetime.datetime.utcnow() - \
            datetime.timedelta(minutes=10)

        reminder = self.user.reminders.create(
            message="test",
            phone_number='123',
        )

        reminder.times.create(
            time='10:00',
            last_run=ten_min_ago,
        )

class TriggerTest(TestCase):
    def test_trigger_now(self):
        reminder = self.user.reminders.create()

        response = self.assertPOST(
            302,
            {},
            'reminders:trigger', reminder.pk,
            login=True,
        )

        self.assertRedirectsTo(response, 'dashboard:view')
{'fraction_non_alphanumeric': 0.11748708186021213, 'fraction_numerical': 0.013054120206690237, 'mean_word_length': 2.1037974683544305, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2863739', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1083, 'n_words': 171}