示例#1
0
    def test_edit(self):
        """
        Check that editing settings in multi-site mode edits the correct
        setting, and leaves the other ones alone
        """
        TestSetting.objects.create(
            title='default',
            email='*****@*****.**',
            site=self.default_site)
        TestSetting.objects.create(
            title='other',
            email='*****@*****.**',
            site=self.other_site)
        response = self.post(site_pk=self.other_site.pk, post_data={
            'title': 'other-new', 'email': '*****@*****.**'})
        self.assertEqual(response.status_code, 302)

        # Check that the correct setting was updated
        other_setting = TestSetting.for_site(self.other_site)
        self.assertEqual(other_setting.title, 'other-new')
        self.assertEqual(other_setting.email, '*****@*****.**')

        # Check that the other setting was not updated
        default_setting = TestSetting.for_site(self.default_site)
        self.assertEqual(default_setting.title, 'default')
        self.assertEqual(default_setting.email, '*****@*****.**')
示例#2
0
    def test_edit(self):
        """
        Check that editing settings in multi-site mode edits the correct
        setting, and leaves the other ones alone
        """
        TestSetting.objects.create(title="default",
                                   email="*****@*****.**",
                                   site=self.default_site)
        TestSetting.objects.create(title="other",
                                   email="*****@*****.**",
                                   site=self.other_site)
        response = self.post(
            site_pk=self.other_site.pk,
            post_data={
                "title": "other-new",
                "email": "*****@*****.**"
            },
        )
        self.assertEqual(response.status_code, 302)

        # Check that the correct setting was updated
        other_setting = TestSetting.for_site(self.other_site)
        self.assertEqual(other_setting.title, "other-new")
        self.assertEqual(other_setting.email, "*****@*****.**")

        # Check that the other setting was not updated
        default_setting = TestSetting.for_site(self.default_site)
        self.assertEqual(default_setting.title, "default")
        self.assertEqual(default_setting.email, "*****@*****.**")
示例#3
0
 def test_for_site_returns_expected_settings(self):
     for site, expected_site_settings in (
         (self.default_site, self.default_site_settings),
         (self.other_site, self.other_site_settings),
     ):
         with self.subTest(site=site):
             self.assertEqual(TestSetting.for_site(site),
                              expected_site_settings)
示例#4
0
    def test_edit(self):
        """
        Check that editing settings in multi-site mode edits the correct
        setting, and leaves the other ones alone
        """
        TestSetting.objects.create(title="default", email="*****@*****.**", site=self.default_site)
        TestSetting.objects.create(title="other", email="*****@*****.**", site=self.other_site)
        response = self.post(
            site_pk=self.other_site.pk, post_data={"title": "other-new", "email": "*****@*****.**"}
        )
        self.assertEqual(response.status_code, 302)

        # Check that the correct setting was updated
        other_setting = TestSetting.for_site(self.other_site)
        self.assertEqual(other_setting.title, "other-new")
        self.assertEqual(other_setting.email, "*****@*****.**")

        # Check that the other setting was not updated
        default_setting = TestSetting.for_site(self.default_site)
        self.assertEqual(default_setting.title, "default")
        self.assertEqual(default_setting.email, "*****@*****.**")