From b0e3c7d4565aa687451b83707cdf4649a5fa58d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Mon, 21 Oct 2013 19:03:07 +0200 Subject: [PATCH] Fix missing url_name_args = [] lines in different views. Fix custom slide create and update view. Fix motion category create and update view. --- openslides/motion/views.py | 2 ++ openslides/projector/views.py | 2 ++ tests/motion/test_views.py | 26 ++++++++++++++++++++++ tests/projector/test_views.py | 42 +++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 tests/projector/test_views.py diff --git a/openslides/motion/views.py b/openslides/motion/views.py index 9af173707..adf46644b 100644 --- a/openslides/motion/views.py +++ b/openslides/motion/views.py @@ -755,6 +755,7 @@ class CategoryCreateView(CreateView): permission_required = 'motion.can_manage_motion' model = Category success_url_name = 'motion_category_list' + url_name_args = [] category_create = CategoryCreateView.as_view() @@ -763,6 +764,7 @@ class CategoryUpdateView(UpdateView): permission_required = 'motion.can_manage_motion' model = Category success_url_name = 'motion_category_list' + url_name_args = [] category_update = CategoryUpdateView.as_view() diff --git a/openslides/projector/views.py b/openslides/projector/views.py index 1d1af58f4..3611772d8 100644 --- a/openslides/projector/views.py +++ b/openslides/projector/views.py @@ -249,6 +249,7 @@ class CustomSlideCreateView(CreateView): model = ProjectorSlide context_object_name = 'customslide' success_url_name = 'dashboard' + url_name_args = [] class CustomSlideUpdateView(UpdateView): @@ -260,6 +261,7 @@ class CustomSlideUpdateView(UpdateView): model = ProjectorSlide context_object_name = 'customslide' success_url_name = 'dashboard' + url_name_args = [] class CustomSlideDeleteView(DeleteView): diff --git a/tests/motion/test_views.py b/tests/motion/test_views.py index 2093f46d2..526f3e70c 100644 --- a/tests/motion/test_views.py +++ b/tests/motion/test_views.py @@ -465,3 +465,29 @@ class TestVersionDeleteView(MotionViewTestCase): self.assertEqual(motion.get_active_version().title, 'new_title_yae6Aequaiw5saeb8suG') response = self.admin_client.post('/motion/1/version/2/del/', {'yes': 1}) self.assertEqual(response.status_code, 404) + + +class CategoryViewsTest(TestCase): + def setUp(self): + self.admin_client = Client() + self.admin_client.login(username='admin', password='admin') + + def test_create(self): + url = '/motion/category/new/' + response = self.admin_client.get(url) + self.assertTemplateUsed(response, 'motion/category_form.html') + response = self.admin_client.post(url, {'name': 'test_title_eingee0hiveeZ6coohoo'}) + self.assertRedirects(response, '/motion/category/') + self.assertTrue(Category.objects.filter(name='test_title_eingee0hiveeZ6coohoo').exists()) + + def test_update(self): + # Setup + url = '/motion/category/1/edit/' + Category.objects.create(name='test_title_chu6zu3deithae1gooL1') + # Test + response = self.admin_client.get(url) + self.assertTemplateUsed(response, 'motion/category_form.html') + self.assertContains(response, 'test_title_chu6zu3deithae1gooL1') + response = self.admin_client.post(url, {'name': 'test_title_jaiShae1sheingahlee2'}) + self.assertRedirects(response, '/motion/category/') + self.assertEqual(Category.objects.get(pk=1).name, 'test_title_jaiShae1sheingahlee2') diff --git a/tests/projector/test_views.py b/tests/projector/test_views.py new file mode 100644 index 000000000..468081242 --- /dev/null +++ b/tests/projector/test_views.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" + Tests for openslides.projector.views + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + TODO: Move this test to the correct place when the projector app is cleaned up. + + :copyright: 2011–2013 by OpenSlides team, see AUTHORS. + :license: GNU GPL, see LICENSE for more details. +""" + +from django.test.client import Client + +from openslides.projector.models import ProjectorSlide +from openslides.utils.test import TestCase + + +class CustomSlidesTest(TestCase): + def setUp(self): + self.admin_client = Client() + self.admin_client.login(username='admin', password='admin') + + def test_create(self): + url = '/projector/new/' + response = self.admin_client.get(url) + self.assertTemplateUsed(response, 'projector/new.html') + response = self.admin_client.post(url, {'title': 'test_title_roo2xi2EibooHie1kohd', 'weight': '0'}) + self.assertRedirects(response, '/projector/dashboard/') + self.assertTrue(ProjectorSlide.objects.filter(title='test_title_roo2xi2EibooHie1kohd').exists()) + + def test_update(self): + # Setup + url = '/projector/1/edit/' + ProjectorSlide.objects.create(title='test_title_jeeDeB3aedei8ahceeso') + # Test + response = self.admin_client.get(url) + self.assertTemplateUsed(response, 'projector/new.html') + self.assertContains(response, 'test_title_jeeDeB3aedei8ahceeso') + response = self.admin_client.post(url, {'title': 'test_title_ai8Ooboh5bahr6Ee7goo', 'weight': '0'}) + self.assertRedirects(response, '/projector/dashboard/') + self.assertEqual(ProjectorSlide.objects.get(pk=1).title, 'test_title_ai8Ooboh5bahr6Ee7goo')