Esempio n. 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'])
Esempio n. 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()
Esempio n. 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()
Esempio n. 4
0
 def test_user_is_owner(self):
     user = get_user('us-ignite')
     resource = fixtures.get_resource(contact=user)
     eq_(resource.is_editable_by(user), True)
Esempio n. 5
0
 def test_resource_is_draft(self):
     resource = fixtures.get_resource(status=Resource.DRAFT)
     eq_(resource.is_draft(), True)
Esempio n. 6
0
 def test_empty_resource_url(self):
     user = get_user('us-ignite')
     resource = fixtures.get_resource(contact=user)
     eq_(resource.get_resource_url(), '')
Esempio n. 7
0
 def test_get_resource_url(self):
     user = get_user('us-ignite')
     resource = fixtures.get_resource(
         contact=user, url='http://us-ignite.org')
     eq_(resource.get_resource_url(), 'http://us-ignite.org')
Esempio n. 8
0
 def test_get_edit_url(self):
     user = get_user('us-ignite')
     resource = fixtures.get_resource(contact=user, slug='foo')
     eq_(resource.get_edit_url(), '/resources/foo/edit/')
Esempio n. 9
0
 def unpublished_resource_can_be_viewed_by_owner(self):
     user = get_user('us-ignite')
     resource = fixtures.get_resource(contact=user, status=Resource.DRAFT)
     eq_(resource.is_visible_by(user), True)
Esempio n. 10
0
 def test_unpublished_resource_is_not_visible(self):
     user = get_user('us-ignite')
     resource = fixtures.get_resource(contact=user, status=Resource.DRAFT)
     eq_(resource.is_visible_by(utils.get_anon_mock()), False)
Esempio n. 11
0
 def test_is_visible(self):
     user = get_user('us-ignite')
     resource = fixtures.get_resource(contact=user, status=Resource.PUBLISHED)
     eq_(resource.is_published(), True)
Esempio n. 12
0
 def test_not_featured_resource_is_not_returned(self):
     user = get_user('us-ignite')
     resource = fixtures.get_resource(
         contact=user, status=Resource.PUBLISHED, is_featured=False)
     eq_(Resource.published.get_featured(), None)
Esempio n. 13
0
 def test_unpublished_resources_are_not_returned(self):
     user = get_user('us-ignite')
     resource = fixtures.get_resource(contact=user, status=Resource.DRAFT)
     eq_(list(Resource.published.all()), [])
Esempio n. 14
0
 def test_published_resources_are_returned(self):
     user = get_user('us-ignite')
     resource = fixtures.get_resource(contact=user, status=Resource.PUBLISHED)
     eq_(list(Resource.published.all()), [resource])
Esempio n. 15
0
 def test_resource_allows_null_contact(self):
     resource = fixtures.get_resource(contact=None)
     ok_(resource.id)
     eq_(resource.contact, None)
Esempio n. 16
0
 def test_ownerless_resource_is_not_editable(self):
     user = get_user('us-ignite')
     resource = fixtures.get_resource(contact=None)
     ok_(not resource.is_editable_by(user))
     ok_(not resource.is_editable_by(utils.get_anon_mock()))
Esempio n. 17
0
 def test_visible_resource_is_published(self):
     user = get_user('us-ignite')
     resource = fixtures.get_resource(contact=user, status=Resource.PUBLISHED)
     eq_(resource.is_visible_by(utils.get_anon_mock()), True)