Browse Source

test liste des services

Élie Bouttier 8 years ago
parent
commit
9ab130ad95
2 changed files with 20 additions and 2 deletions
  1. 1 1
      djadhere/tests.py
  2. 19 1
      services/tests.py

+ 1 - 1
djadhere/tests.py

@@ -3,7 +3,7 @@ from django.core.urlresolvers import reverse
 from django.test import TestCase
 
 
-class AccountsTests(TestCase):
+class DjadhereTests(TestCase):
     def setUp(self):
         user = User.objects.create_user('user', email='user@example.net', password='user')
 

+ 19 - 1
services/tests.py

@@ -1,3 +1,21 @@
+from django.contrib.auth.models import User
+from django.core.urlresolvers import reverse
 from django.test import TestCase
+from django.contrib.contenttypes.models import ContentType
 
-# Create your tests here.
+from adhesions.models import Adherent
+from .models import Service, ServiceType
+
+
+class ServicesTests(TestCase):
+    def setUp(self):
+        user = User.objects.create_user('user', email='user@example.net', password='user')
+        adh = Adherent.objects.create(adherent_type=ContentType.objects.get_for_model(user), adherent_id=user.pk)
+        stype = ServiceType.objects.create(name='VM')
+        s1 = Service.objects.create(adherent=adh, service_type=stype, label='Service 1')
+
+    def test_service_list(self):
+        self.client.login(username='user', password='user')
+        response = self.client.get(reverse('service-list'))
+        self.assertEqual(response.status_code, 200)
+        self.assertContains(response, 'Service 1')