Parcourir la source

Fix maillists module tests

Probably broken in 2b59d86
Jocelyn Delalande il y a 6 ans
Parent
commit
4a177811aa
1 fichiers modifiés avec 15 ajouts et 5 suppressions
  1. 15 5
      maillists/tests.py

+ 15 - 5
maillists/tests.py

@@ -7,7 +7,7 @@ from django.conf import settings
 from django.test import TestCase, override_settings
 
 from coin.members.models import Member
-from .models import MaillingList
+from .models import MaillingList, MaillingListSubscription
 
 
 @override_settings()
@@ -43,25 +43,35 @@ class SubscriptionTestCase(TestCase):
         shutil.rmtree(self.tmpdir)
 
     def test_subscription_sync(self):
-        self.ml.subscribers.add(self.member)
+        sub1 = MaillingListSubscription.objects.create(
+            member=self.member,
+            maillinglist=self.ml,
+        )
 
         self.assertTrue(exists(self.ml_file))
         self.assertEqual(open(self.ml_file).read(), 'toto@example.com')
 
-        self.ml.subscribers.add(self.member2)
+        MaillingListSubscription.objects.create(
+            member=self.member2,
+            maillinglist=self.ml,
+        )
+
         self.assertEqual(
             open(self.ml_file).read(),
             'toto@example.com\nlolo@example.com',
         )
 
-        self.ml.subscribers.remove(self.member)
+        sub1.delete()
         self.assertEqual(
             open(self.ml_file).read(),
             'lolo@example.com',
         )
 
     def test_email_change_update_subscriptions(self):
-        self.ml.subscribers.add(self.member)
+        MaillingListSubscription.objects.create(
+            member=self.member,
+            maillinglist=self.ml,
+        )
 
         # then, change member email
         self.member.email = 'tata@example.com'