Beispiel #1
0
 def test_get_request_is_successful(self):
     request = utils.get_request(
         'get', '/resource/add/', user=utils.get_user_mock())
     response = views.resource_add(request)
     eq_(response.status_code, 200)
     eq_(response.template_name, 'resources/object_add.html')
     eq_(sorted(response.context_data.keys()), ['form'])
Beispiel #2
0
 def test_post_request_succeeds(self):
     user = get_user('us-ignite')
     data = {
         'name': 'Gigabit resource',
         'description': 'Lorem Ipsum',
         'status': Resource.DRAFT,
         'url': 'http://us-ignite.org/',
     }
     request = utils.get_request(
         'post', '/resource/add/', data=data, user=user)
     response = views.resource_add(request)
     resource = Resource.objects.get(name='Gigabit resource')
     eq_(response.status_code, 302)
     eq_(response['Location'], resource.get_absolute_url())
     eq_(resource.contact, user)
     self._tear_down()
Beispiel #3
0
 def test_empty_post_request_fails(self):
     request = utils.get_request(
         'post', '/resource/add/', data={}, user=utils.get_user_mock())
     response = views.resource_add(request)
     eq_(response.status_code, 200)
     ok_(response.context_data['form'].errors)
Beispiel #4
0
 def test_view_requires_authentication(self):
     request = utils.get_request(
         'get', '/resource/add/', user=utils.get_anon_mock())
     response = views.resource_add(request)
     eq_(response.status_code, 302)
     eq_(response['Location'], utils.get_login_url('/resource/add/'))