

def test_post_with_creator(self):
    data = {
        'name': 'test app',
        'description': '',
        'download_url': 'http://example.com',
        'redirect_uris': 'http://example.com',
        'authorization_grant_type': 'password',
    }
    view = ApplicationSettings.as_view()
    url = reverse('admin:app_settings', kwargs={
        'app_id': self.app.id,
    })
    request = APIRequestFactory().post(url, data)
    request.user = self.creator
    from django.contrib.messages.storage.fallback import FallbackStorage
    setattr(request, 'session', 'session')
    messages = FallbackStorage(request)
    setattr(request, '_messages', messages)
    response = view(request, app_id=self.app.id).render()
    self.assertEqual(response.status_code, 200)
    self.assertNotContains(response, 'You are not the owner of this application and therefore notallowed to access this app.')
    ref = Application.objects.get(pk=self.app.id)
    self.assertEqual(ref.name, data.get('name'))
    self.assertEqual(ref.description, data.get('description'))
    self.assertEqual(ref.download_url, data.get('download_url'))
    self.assertEqual(ref.redirect_uris, data.get('redirect_uris'))
    self.assertEqual(ref.authorization_grant_type, data.get('authorization_grant_type'))

dataset/ETHPy150Open ExCiteS/geokey/geokey/applications/tests/test_views.py ApplicationSettingsTest.test_post_with_creator/original