Esempio n. 1
0
    def test_free_trial_ending__no_free_trial(self):
        """
        If there is no active subscription, the ending warning shouldn't be
        sent.

        """
        tier = self.create_tier()
        tier_info = self.create_tier_info(tier)

        self.assertEqual(len(mail.outbox), 0)
        with mock.patch.object(tier_info, 'subscription', None):
            send_free_trial_ending()
        self.assertEqual(len(mail.outbox), 0)
Esempio n. 2
0
    def test_free_trial_ending__late(self):
        """
        If we're past the warning period, the free trial ending warning
        shouldn't be sent, even if all other conditions are met.

        """
        tier = self.create_tier()
        tier_info = self.create_tier_info(tier)

        trial_end = datetime.datetime.now() - datetime.timedelta(2)
        self.assertEqual(len(mail.outbox), 0)
        with mock.patch.object(tier_info, 'subscription',
                               free_trial_end=trial_end):
            send_free_trial_ending()
        self.assertEqual(len(mail.outbox), 0)
Esempio n. 3
0
    def test_free_trial_ending(self):
        """
        If all conditions are met, the site owner(s) should be emailed.

        """
        tier = self.create_tier()
        tier_info = self.create_tier_info(tier)

        trial_end = datetime.datetime.now() + datetime.timedelta(2)
        self.assertEqual(len(mail.outbox), 0)
        with mock.patch.object(tier_info, 'subscription',
                               mock.Mock(free_trial_end=trial_end)):
            send_free_trial_ending()
        self.assertEqual(len(mail.outbox), 1)
        self.assertTrue(tier_info.free_trial_ending_sent)
        self.assertEqual(mail.outbox[0].to, [self.owner.email])
Esempio n. 4
0
    def test_free_trial_ending__sent(self):
        """
        If the free trial ending warning was already sent, we shouldn't send
        it again, even if all other conditions are met.

        """
        now = datetime.datetime.now()
        tier = self.create_tier()
        tier_info = self.create_tier_info(tier, free_trial_ending_sent=now)

        trial_end = now + datetime.timedelta(2)
        self.assertEqual(len(mail.outbox), 0)
        with mock.patch.object(tier_info, 'subscription',
                               free_trial_end=trial_end):
            send_free_trial_ending()
        self.assertEqual(len(mail.outbox), 0)
 def handle_noargs(self, **options):
     send_free_trial_ending()