예제 #1
0
    def test_accept_entries_user_not_unique(self, check_unique_user):
        check_unique_user.return_value = False

        self.e2.status = Entry.STATUS_REVIEW
        self.e2.save()
        self.e3.status = Entry.STATUS_REVIEW
        self.e3.save()

        rows_updated = services.accept_entries(1, Entry.objects.all())

        self.assertEqual(rows_updated, 0)
        self.assertEqual(Entry.objects.filter(status=Entry.STATUS_ACCEPTED).count(), 2)
        self.assertEqual(len(mail.outbox), 0)
예제 #2
0
    def test_accept_entries_manual_username(self):
        self.e2.status = Entry.STATUS_REVIEW
        self.e2.username = "******"
        self.e2.save()
        self.e3.status = Entry.STATUS_REVIEW
        self.e3.save()

        rows_updated = services.accept_entries(1, Entry.objects.all())

        self.e2.refresh_from_db()
        self.assertEqual(self.e2.username, "manual_username")

        self.assertEqual(rows_updated, 3)
        self.assertEqual(Entry.objects.filter(status=Entry.STATUS_ACCEPTED).count(), 5)
        self.assertEqual(len(mail.outbox), 2)