Permalink
Browse files

do not rely on backends order, fixed tox, bump django version on travis

  • Loading branch information...
1 parent 2d7fb53 commit 23f0afe65ed6dfda9223adb20b89d18ab3b21f6e Massimiliano Pippi committed Oct 16, 2013
View
@@ -2,8 +2,8 @@ language: python
python:
- "2.7"
env:
- - DJANGO=1.4
- - DJANGO=1.5
+ - DJANGO=1.4.8
+ - DJANGO=1.5.4
install:
- pip install -q Django==$DJANGO --use-mirrors
- pip install -q django-nose --use-mirrors
@@ -14,4 +14,4 @@ install:
before_script:
- "./lint.sh"
script:
- - python runtests.py
+ - python runtests.py
@@ -0,0 +1,8 @@
+from ..models import NOTICE_MEDIA
+
+
+def get_backend_id(backend_name):
+ for bid, bname in NOTICE_MEDIA:
+ if bname == backend_name:
+ return bid
+ return None
@@ -8,12 +8,14 @@
from django.utils.six.moves import cPickle as pickle # pylint: disable-msg=F
from ..models import NoticeType, NoticeSetting, NoticeQueueBatch
-from ..models import NOTICE_MEDIA, LanguageStoreNotAvailable
+from ..models import LanguageStoreNotAvailable
from ..models import get_notification_language, create_notice_type, send_now, send, queue
from ..compat import get_user_model
from .models import Language
+from . import get_backend_id
+
class BaseTest(TestCase):
def setUp(self):
@@ -52,7 +54,7 @@ def test_create(self):
class TestNoticeSetting(BaseTest):
def test_for_user(self):
- email_id = NOTICE_MEDIA[0][0]
+ email_id = get_backend_id("email")
notice_setting = NoticeSetting.objects.create(user=self.user, notice_type=self.notice_type,
medium=email_id, send=False)
self.assertEqual(NoticeSetting.for_user(self.user, self.notice_type, email_id),
@@ -2,7 +2,9 @@
from django.core.urlresolvers import reverse
from ..compat import get_user_model
-from ..models import create_notice_type, NoticeSetting, NoticeType, NOTICE_MEDIA
+from ..models import create_notice_type, NoticeSetting, NoticeType
+
+from . import get_backend_id
class TestViews(TestCase):
@@ -20,17 +22,18 @@ def test_notice_settings(self):
notice_type_1 = NoticeType.objects.get(label="label_1")
create_notice_type("label_2", "display", "description")
notice_type_2 = NoticeType.objects.get(label="label_2")
- setting = NoticeSetting.for_user(self.user, notice_type_2, NOTICE_MEDIA[0][0])
+ email_id = get_backend_id("email")
+ setting = NoticeSetting.for_user(self.user, notice_type_2, email_id)
setting.send = False
setting.save()
self.client.login(username="test_user", password="123456")
response = self.client.get(reverse("notification_notice_settings"))
self.assertEqual(response.status_code, 200) # pylint: disable-msg=E1103
post_data = {
- "label_2_{}".format(NOTICE_MEDIA[0][0]): "on",
+ "label_2_{}".format(email_id): "on",
}
response = self.client.post(reverse("notification_notice_settings"), data=post_data)
self.assertEqual(response.status_code, 302) # pylint: disable-msg=E1103
- self.assertFalse(NoticeSetting.for_user(self.user, notice_type_1, NOTICE_MEDIA[0][0]).send)
- self.assertTrue(NoticeSetting.for_user(self.user, notice_type_2, NOTICE_MEDIA[0][0]).send)
+ self.assertFalse(NoticeSetting.for_user(self.user, notice_type_1, email_id).send)
+ self.assertTrue(NoticeSetting.for_user(self.user, notice_type_2, email_id).send)
@@ -1,2 +1 @@
--r common.txt
-django-nose
+django-nose

0 comments on commit 23f0afe

Please sign in to comment.