s/cofprofile/profile/g into k-fêt.

This commit also restores the only unittest present.
This commit is contained in:
Michele Orrù 2017-02-10 22:58:01 +01:00
parent f39d1545f0
commit 22da04c3e2
9 changed files with 158 additions and 150 deletions

View file

@ -63,17 +63,6 @@ class CofProfile(models.Model):
return self.user.username
@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
CofProfile.objects.get_or_create(user=instance)
@receiver(post_delete, sender=CofProfile)
def post_delete_user(sender, instance, *args, **kwargs):
instance.user.delete()
@python_2_unicode_compatible
class Club(models.Model):
name = models.CharField("Nom", max_length=200, unique=True)

View file

@ -1,33 +1,3 @@
# -*- coding: utf-8 -*-
"""
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 __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from django.test import TestCase
from .models import CofProfile, User
class SimpleTest(TestCase):
def test_delete_user(self):
u = User(username='foo', first_name='foo', last_name='bar')
# to each user there's a cofprofile associated
u.save()
self.assertTrue(CofProfile.objects.filter(user__username='foo').exists())
# there's no point in having a cofprofile without a user associated.
u.delete()
self.assertFalse(CofProfile.objects.filter(user__username='foo').exists())
# there's no point in having a user without a cofprofile associated.
u.save()
CofProfile.objects.get(user__username='foo').delete()
self.assertFalse(User.objects.filter(username='foo').exists())
# Create your tests here.