1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-07-04 02:52:08 +02:00

Fully test logs app

This commit is contained in:
Yohann D'ANELLO
2020-09-24 14:30:24 +02:00
parent 1979d33314
commit a2ce495a6b
4 changed files with 34 additions and 7 deletions

21
apps/logs/tests.py Normal file
View File

@ -0,0 +1,21 @@
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
from django.test import TestCase
from .models import Changelog
class TestChangelog(TestCase):
def test_logs(self):
user = User.objects.create(email="admin@example.com")
self.assertTrue(Changelog.objects.filter(action="create", instance_pk=user.pk,
model=ContentType.objects.get_for_model(User)).exists())
old_user_pk = user.pk
user.delete()
self.assertTrue(Changelog.objects.filter(action="delete", instance_pk=old_user_pk,
model=ContentType.objects.get_for_model(User)).exists())
changelog = Changelog.objects.first()
self.assertRaises(ValidationError, changelog.delete)
str(Changelog.objects.all())