from django.test import TestCase from django.core.urlresolvers import reverse from django.core.management import call_command from core.models import User from club.models import Club # Create your tests here. class ClubTest(TestCase): def setUp(self): call_command("populate") self.skia = User.objects.filter(username="skia").first() self.rbatsbak = User.objects.filter(username="rbatsbak").first() self.guy = User.objects.filter(username="guy").first() self.bdf = Club.objects.filter(unix_name="bdf").first() def test_create_add_user_to_club_from_root_ok(self): self.client.login(username='root', password='plop') self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), { "user": self.skia.id, "start_date": "12/06/2016", "role": 3}) response = self.client.get(reverse("club:club_members", kwargs={"club_id":self.bdf.id})) self.assertTrue(response.status_code == 200) self.assertTrue("S' Kia\\n Responsable info" in str(response.content)) def test_create_add_user_to_club_from_root_fail_not_subscriber(self): self.client.login(username='root', password='plop') response = self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), { "user": self.guy.id, "start_date": "12/06/2016", "role": 3}) self.assertTrue(response.status_code == 200) self.assertTrue('