def test_contact_request_is_successful(self): contact = get_user('contact') hub = fixtures.get_hub( name='community', status=models.Hub.PUBLISHED, contact=contact) request = utils.get_request( 'get', '/hub/community/edit/', user=contact) response = views.hub_edit(request, 'community') eq_(response.status_code, 200) eq_(response.template_name, 'hubs/object_edit.html') eq_(sorted(response.context_data.keys()), sorted(['form', 'object'])) eq_(response.context_data['object'], hub)
def test_contact_update_is_successful(self): contact = get_user('contact') hub = fixtures.get_hub( name='community', status=models.Hub.PUBLISHED, contact=contact) data = { 'name': 'New name!', 'description': 'New description.' } request = utils.get_request( 'post', '/hub/community/edit/', data=data, user=contact) request._messages = utils.TestMessagesBackend(request) response = views.hub_edit(request, 'community') eq_(response.status_code, 302) eq_(response['Location'], hub.get_absolute_url()) eq_(models.Hub.objects.values('name').get(slug='community'), {'name': 'New name!'})
def test_not_contact_request_fails(self): user = get_user('us-ignite') fixtures.get_hub(name='community', status=models.Hub.PUBLISHED) request = utils.get_request('get', '/hub/community/edit/', user=user) views.hub_edit(request, 'community')
def test_anon_request_fails(self): user = utils.get_anon_mock() request = utils.get_request('get', '/hub/community/edit/', user=user) response = views.hub_edit(request, 'community') eq_(response.status_code, 302) eq_(response['Location'], utils.get_login_url('/hub/community/edit/'))