Exemple #1
0
 def test_resource_request_is_successsful(self):
     user = get_user('us-ignite')
     resource = fixtures.get_resource(contact=user)
     request = utils.get_request('get', resource.get_edit_url(), user=user)
     response = views.resource_edit(request, resource.slug)
     eq_(response.status_code, 200)
     eq_(response.template_name, 'resources/object_edit.html')
     eq_(sorted(response.context_data.keys()), ['form', 'object'])
Exemple #2
0
 def test_invalid_form_fails(self):
     user = get_user('us-ignite')
     resource = fixtures.get_resource(contact=user)
     request = utils.get_request(
         'post', resource.get_edit_url(), data={}, user=user)
     response = views.resource_edit(request, resource.slug)
     eq_(response.status_code, 200)
     ok_(response.context_data['form'].errors)
     self._tear_down()
Exemple #3
0
 def test_resource_update_request_is_successful(self):
     user = get_user('us-ignite')
     resource = fixtures.get_resource(contact=user)
     data = {
         'name': 'Resource Updated',
         'description': 'Lorem Ipsum',
         'status': Resource.DRAFT,
         'url': 'http://us-ignite.org/',
     }
     request = utils.get_request(
         'post', resource.get_edit_url(), data=data, user=user)
     response = views.resource_edit(request, resource.slug)
     eq_(response.status_code, 302)
     eq_(response['Location'], resource.get_absolute_url())
     resource = Resource.objects.get(pk=resource.pk)
     eq_(resource.name, 'Resource Updated')
     self._tear_down()
Exemple #4
0
 def test_view_requires_authentication(self):
     request = utils.get_request(
         'get', '/resource/foo/edit/', user=utils.get_anon_mock())
     response = views.resource_edit(request)
     eq_(response.status_code, 302)
     eq_(response['Location'], utils.get_login_url('/resource/foo/edit/'))