~netlandish/django-wiki

5440c6fc844667e77c5661c772ab1953cb375df5 — Benjamin Bach 4 years ago efed941
Create Settings object for notification tests just when needed
1 files changed, 6 insertions(+), 6 deletions(-)

M tests/plugins/notifications/test_views.py
M tests/plugins/notifications/test_views.py => tests/plugins/notifications/test_views.py +6 -6
@@ 1,16 1,12 @@
import pdb

from django.shortcuts import resolve_url
from django_nyt.models import Settings

from tests.base import RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestBase
from tests.base import ArticleWebTestUtils, DjangoClientTestBase, RequireRootArticleMixin


class NotificationSettingsTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestBase):

    def setUp(self):
        super().setUp()
        self.settings = Settings.objects.get_or_create(user=self.superuser1, is_default=True)

    def test_login_required(self):
        self.client.logout()


@@ 23,6 19,8 @@ class NotificationSettingsTests(RequireRootArticleMixin, ArticleWebTestUtils, Dj
        self.assertTemplateUsed(response, 'wiki/plugins/notifications/settings.html')

    def test_change_settings(self):
        self.settings, __ = Settings.objects.get_or_create(user=self.superuser1, is_default=True)

        url = resolve_url('wiki:notification_settings')

        response = self.client.get(url)


@@ 47,4 45,6 @@ class NotificationSettingsTests(RequireRootArticleMixin, ArticleWebTestUtils, Dj
        data['form-0-email'] = 2
        # post the request without any change
        response = self.client.post(url, data)
        self.root_article.refresh_from_db()

        # Ensure we didn't create redundant Settings objects
        assert self.superuser1.nyt_settings.all().count() == 1