Beispiel #1
0
    def test_post(self):
        from django.contrib.auth.models import User

        rf = RequestFactory()
        request = rf.post('/dummy',
                          {'TEST_SETTING': 'after',
                           'BOSS': 'mio'})
        request.user = User(username='******', is_staff=True)

        with override_websettings(BOSS='ritsu'):
            from websettings import websettings
            target = self._getTarget()
            result = target(request)

            self.assertEqual(websettings.TEST_SETTING, 'after')
            self.assertEqual(websettings.BOSS, 'mio')
            self.assertEqual(302, result.status_code)
Beispiel #2
0
    def test_get(self):
        from django.contrib.auth.models import User

        rf = RequestFactory()
        request = rf.get('/dummy')
        request.user = User(username='******', is_staff=True)

        with override_websettings(BOSS='ritsu'):
            from websettings.forms import SettingStoreForm
            target = self._getTarget()

            result = target(request)
            form = result.context_data['form']

            self.assertTrue(isinstance(form, SettingStoreForm))
            self.assertEqual({'TEST_SETTING', 'BOSS'},
                             set(form.fields.keys()))
            self.assertTemplateUsed(result, 'websettings/edit.html')