2012-06-27 23:28:35 +02:00
|
|
|
"""
|
|
|
|
This file demonstrates writing tests using the unittest module. These will pass
|
|
|
|
when you run "manage.py test".
|
|
|
|
|
|
|
|
Replace this with more appropriate tests for your application.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from django.test import TestCase
|
|
|
|
|
2017-01-04 22:32:50 +01:00
|
|
|
from gestioncof.models import CofProfile, User
|
|
|
|
|
2012-06-27 23:28:35 +02:00
|
|
|
|
|
|
|
class SimpleTest(TestCase):
|
2017-01-04 22:32:50 +01:00
|
|
|
def test_delete_user(self):
|
2018-10-06 12:35:49 +02:00
|
|
|
u = User(username="foo", first_name="foo", last_name="bar")
|
2017-01-04 22:32:50 +01:00
|
|
|
|
|
|
|
# to each user there's a cofprofile associated
|
|
|
|
u.save()
|
2018-10-06 12:35:49 +02:00
|
|
|
self.assertTrue(CofProfile.objects.filter(user__username="foo").exists())
|
2017-01-04 22:32:50 +01:00
|
|
|
|
|
|
|
# there's no point in having a cofprofile without a user associated.
|
|
|
|
u.delete()
|
2018-10-06 12:35:49 +02:00
|
|
|
self.assertFalse(CofProfile.objects.filter(user__username="foo").exists())
|
2017-01-04 22:32:50 +01:00
|
|
|
|
|
|
|
# there's no point in having a user without a cofprofile associated.
|
|
|
|
u.save()
|
2018-10-06 12:35:49 +02:00
|
|
|
CofProfile.objects.get(user__username="foo").delete()
|
|
|
|
self.assertFalse(User.objects.filter(username="foo").exists())
|