Ejemplo n.º 1
0
    def testRemoveEmailReminder(self):
        """
        Test that unchecking send_email will remove the reminder.
        """
        event = test_utils.create_event()

        reminder = EmailReminder(
            user=self.user,
            action=event,
            email_address="*****@*****.**",
            send_at=event.event_date - datetime.timedelta(hours=2),
        )
        reminder.save()
        reminder_count = self.user.emailreminder_set.count()

        response = self.client.post(reverse("activity_reminder", args=(event.type, event.slug,)), {
            "send_email": False,
            "email": "",
            "email_advance": "1",
            "send_text": False,
            "text_advance": "1",
            }, HTTP_X_REQUESTED_WITH="XMLHttpRequest")
        self.failUnlessEqual(response.status_code, 200)

        self.assertEqual(self.user.emailreminder_set.count(), reminder_count - 1,
            "User should not have a reminder.")
Ejemplo n.º 2
0
    def testRemoveEmailReminder(self):
        """
        Test that unchecking send_email will remove the reminder.
        """
        event = test_utils.create_event()

        reminder = EmailReminder(
            user=self.user,
            action=event,
            email_address="*****@*****.**",
            send_at=event.event_date - datetime.timedelta(hours=2),
        )
        reminder.save()
        reminder_count = self.user.emailreminder_set.count()

        response = self.client.post(reverse("activity_reminder",
                                            args=(
                                                event.type,
                                                event.slug,
                                            )), {
                                                "send_email": False,
                                                "email": "",
                                                "email_advance": "1",
                                                "send_text": False,
                                                "text_advance": "1",
                                            },
                                    HTTP_X_REQUESTED_WITH="XMLHttpRequest")
        self.failUnlessEqual(response.status_code, 200)

        self.assertEqual(self.user.emailreminder_set.count(),
                         reminder_count - 1,
                         "User should not have a reminder.")
Ejemplo n.º 3
0
    def testChangeEmailReminder(self):
        """
        Test that we can adjust a reminder.
        """
        event = test_utils.create_event()

        original_date = event.event_date - datetime.timedelta(hours=2)
        reminder = EmailReminder(
            user=self.user,
            action=event,
            email_address="*****@*****.**",
            send_at=original_date,
        )
        reminder.save()
        reminder_count = self.user.emailreminder_set.count()

        response = self.client.post(reverse("activity_reminder", args=(event.type, event.slug,)), {
            "send_email": True,
            "email": "*****@*****.**",
            "email_advance": "1",
            "send_text": False,
            "text_advance": "1",
            }, HTTP_X_REQUESTED_WITH="XMLHttpRequest")
        self.failUnlessEqual(response.status_code, 200)

        reminder = self.user.emailreminder_set.get(action=event)
        profile = Profile.objects.get(user=self.user)
        self.assertEqual(reminder.email_address, "*****@*****.**",
            "Email address should have changed.")
        self.assertEqual(profile.user.email, "*****@*****.**",
            "Profile email address should have changed.")
        self.assertNotEqual(reminder.send_at, original_date, "Send time should have changed.")
        self.assertEqual(self.user.emailreminder_set.count(), reminder_count,
            "No new reminders should have been created.")
Ejemplo n.º 4
0
    def testChangeEmailReminder(self):
        """
        Test that we can adjust a reminder.
        """
        event = test_utils.create_event()

        original_date = event.event_date - datetime.timedelta(hours=2)
        reminder = EmailReminder(
            user=self.user,
            action=event,
            email_address="*****@*****.**",
            send_at=original_date,
        )
        reminder.save()
        reminder_count = self.user.emailreminder_set.count()

        response = self.client.post(reverse("activity_reminder",
                                            args=(
                                                event.type,
                                                event.slug,
                                            )), {
                                                "send_email": True,
                                                "email": "*****@*****.**",
                                                "email_advance": "1",
                                                "send_text": False,
                                                "text_advance": "1",
                                            },
                                    HTTP_X_REQUESTED_WITH="XMLHttpRequest")
        self.failUnlessEqual(response.status_code, 200)

        reminder = self.user.emailreminder_set.get(action=event)
        profile = Profile.objects.get(user=self.user)
        self.assertEqual(reminder.email_address, "*****@*****.**",
                         "Email address should have changed.")
        self.assertEqual(profile.user.email, "*****@*****.**",
                         "Profile email address should have changed.")
        self.assertNotEqual(reminder.send_at, original_date,
                            "Send time should have changed.")
        self.assertEqual(self.user.emailreminder_set.count(), reminder_count,
                         "No new reminders should have been created.")