Browse Source

Fix maillists module tests

Probably broken in 2b59d86
Jocelyn Delalande 6 years ago
parent
commit
4a177811aa
1 changed files with 15 additions and 5 deletions
  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 django.test import TestCase, override_settings
 
 
 from coin.members.models import Member
 from coin.members.models import Member
-from .models import MaillingList
+from .models import MaillingList, MaillingListSubscription
 
 
 
 
 @override_settings()
 @override_settings()
@@ -43,25 +43,35 @@ class SubscriptionTestCase(TestCase):
         shutil.rmtree(self.tmpdir)
         shutil.rmtree(self.tmpdir)
 
 
     def test_subscription_sync(self):
     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.assertTrue(exists(self.ml_file))
         self.assertEqual(open(self.ml_file).read(), 'toto@example.com')
         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(
         self.assertEqual(
             open(self.ml_file).read(),
             open(self.ml_file).read(),
             'toto@example.com\nlolo@example.com',
             'toto@example.com\nlolo@example.com',
         )
         )
 
 
-        self.ml.subscribers.remove(self.member)
+        sub1.delete()
         self.assertEqual(
         self.assertEqual(
             open(self.ml_file).read(),
             open(self.ml_file).read(),
             'lolo@example.com',
             'lolo@example.com',
         )
         )
 
 
     def test_email_change_update_subscriptions(self):
     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
         # then, change member email
         self.member.email = 'tata@example.com'
         self.member.email = 'tata@example.com'