def test_get_list_featured_page(self): """Get list featuredrep page.""" user = UserFactory.create(groups=['Admin']) FeaturedRepFactory.create_batch(3) response = self.get(url=reverse('featuredrep_list_featured'), user=user) self.assertTemplateUsed(response, 'featuredrep_list.html')
def test_get_as_council(self): user = UserFactory.create(groups=['Council']) featured = FeaturedRepFactory.create() response = self.get(url=reverse('featuredrep_edit_featured', args=[featured.id]), user=user) self.assertTemplateUsed(response, 'featuredrep_alter.html')
def test_delete_featured(self, redirect_mock): user = UserFactory.create(groups=['Admin']) featured = FeaturedRepFactory.create() with self.login(user) as client: client.post( reverse('featuredrep_delete_featured', args=[featured.id])) ok_(not FeaturedRep.objects.filter(pk=featured.id).exists())
def test_get_as_council(self): user = UserFactory.create(groups=['Council']) featured = FeaturedRepFactory.create() with self.login(user) as client: response = client.get( reverse('featuredrep_edit_featured', args=[featured.id])) self.assertJinja2TemplateUsed(response, 'featuredrep_alter.jinja')
def test_get_as_other_user(self): user = UserFactory.create() featured = FeaturedRepFactory.create() with self.login(user) as client: client.get(reverse('featuredrep_edit_featured', args=[featured.id]), follow=True)
def test_delete_featured(self, redirect_mock): user = UserFactory.create(groups=['Admin']) featured = FeaturedRepFactory.create() self.post(url=reverse('featuredrep_delete_featured', args=[featured.id]), user=user) ok_(not FeaturedRep.objects.filter(pk=featured.id).exists())
def test_edit_featured(self, form_mock, redirect_mock, messages_mock): form_mock.is_valid.return_value = True featured = FeaturedRepFactory.create() user = UserFactory.create(groups=['Admin']) with self.login(user) as client: response = client.post(reverse('featuredrep_edit_featured', args=[featured.id]), user=user, follow=True) eq_(response.status_code, 200) messages_mock.assert_called_with( mock.ANY, 'Featured rep article successfuly edited.') ok_(form_mock().save.called)
def test_edit_featured(self, form_mock, redirect_mock, messages_mock): form_mock.is_valid.return_value = True featured = FeaturedRepFactory.create() user = UserFactory.create(groups=['Admin']) response = self.post(url=reverse('featuredrep_edit_featured', args=[featured.id]), user=user) eq_(response.status_code, 200) messages_mock.assert_called_with( mock.ANY, 'Featured rep article successfuly edited.') ok_(form_mock().save.called)
def test_delete_featured(self, redirect_mock): user = UserFactory.create(groups=['Admin']) featured = FeaturedRepFactory.create() with self.login(user) as client: client.post(reverse('featuredrep_delete_featured', args=[featured.id])) ok_(not FeaturedRep.objects.filter(pk=featured.id).exists())
def test_get_list_featured_page(self): """Get list featuredrep page.""" UserFactory.create(groups=['Admin']) FeaturedRepFactory.create_batch(3) response = Client().get(reverse('featuredrep_list_featured')) self.assertJinja2TemplateUsed(response, 'featuredrep_list.jinja')
def test_get_as_council(self): user = UserFactory.create(groups=['Council']) featured = FeaturedRepFactory.create() with self.login(user) as client: response = client.get(reverse('featuredrep_edit_featured', args=[featured.id])) self.assertJinja2TemplateUsed(response, 'featuredrep_alter.jinja')
def test_get_as_other_user(self): user = UserFactory.create() featured = FeaturedRepFactory.create() self.get(url=reverse('featuredrep_edit_featured', args=[featured.id]), user=user)