Ejemplo n.º 1
0
    def test_it_sends_notice(self):
        cmd = Command(stdout=Mock())
        cmd.pause = Mock()  # don't pause for 1s

        result = cmd.handle()
        self.assertEqual(result, "Done! Sent 1 notices")

        self.profile.refresh_from_db()
        self.assertTrue(self.profile.deletion_notice_date)

        email = mail.outbox[0]
        self.assertEqual(email.subject, "Inactive Account Notification")
Ejemplo n.º 2
0
    def test_it_checks_last_active_date(self):
        # alice has been browsing the site recently
        self.profile.last_active_date = now() - td(days=15)
        self.profile.save()

        result = Command(stdout=Mock()).handle()
        self.assertEqual(result, "Done! Sent 0 notices")
Ejemplo n.º 3
0
    def test_it_checks_deletion_notice_date(self):
        # alice has already received a deletion notice
        self.profile.deletion_notice_date = now() - td(days=15)
        self.profile.save()

        result = Command(stdout=Mock()).handle()
        self.assertEqual(result, "Done! Sent 0 notices")
Ejemplo n.º 4
0
    def test_it_checks_recent_pings(self):
        check = Check.objects.create(project=self.project)
        Ping.objects.create(owner=check)

        result = Command(stdout=Mock()).handle()
        self.assertEqual(result, "Done! Sent 0 notices")

        self.profile.refresh_from_db()
        self.assertIsNone(self.profile.deletion_notice_date)
Ejemplo n.º 5
0
    def test_it_checks_team_members(self):
        # bob has access to alice's project
        Member.objects.create(user=self.bob, project=self.project)

        result = Command(stdout=Mock()).handle()
        self.assertEqual(result, "Done! Sent 0 notices")

        self.profile.refresh_from_db()
        self.assertIsNone(self.profile.deletion_notice_date)
Ejemplo n.º 6
0
    def test_it_checks_sms_limit(self):
        # alice has a paid account
        self.profile.sms_limit = 50
        self.profile.save()

        result = Command(stdout=Mock()).handle()
        self.assertEqual(result, "Done! Sent 0 notices")

        self.profile.refresh_from_db()
        self.assertIsNone(self.profile.deletion_notice_date)
Ejemplo n.º 7
0
    def test_it_checks_date_joined(self):
        # alice signed up recently:
        self.alice.date_joined = now() - td(days=15)
        self.alice.save()

        result = Command(stdout=Mock()).handle()
        self.assertEqual(result, "Done! Sent 0 notices")

        self.profile.refresh_from_db()
        self.assertIsNone(self.profile.deletion_notice_date)
Ejemplo n.º 8
0
    def test_it_checks_last_login(self):
        # alice has logged in recently:
        self.alice.last_login = now() - td(days=15)
        self.alice.save()

        result = Command(stdout=Mock()).handle()
        self.assertEqual(result, "Done! Sent 0 notices")

        self.profile.refresh_from_db()
        self.assertIsNone(self.profile.deletion_notice_date)