[damned-lies] Fixed obsolete HttpResponse arguments



commit 568ecd0fe59209d45b5b9823a09b26c8f0f6ad19
Author: Claude Paroz <claude 2xlibre net>
Date:   Thu Sep 10 08:58:08 2015 +0200

    Fixed obsolete HttpResponse arguments

 stats/tests/tests.py |   27 +++++++++++++++++++++++++++
 stats/views.py       |    4 ++--
 2 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index ba78bf8..f24f6fb 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -17,6 +17,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
+import json
 import os
 import shutil
 import tarfile
@@ -102,6 +103,15 @@ class ModuleTestCase(TestCase):
     def test_module_methods(self):
         self.assertEqual(self.mod.get_description(), 'gnome-hello')
 
+    def test_modules_list(self):
+        response = self.client.get(reverse('modules'))
+        self.assertContains(response, '<li><a href="/module/zenity/">zenity</a></li>')
+        # Also test JSON output
+        response = self.client.get(reverse('modules', args=['json']))
+        content = json.loads(response.content)
+        self.assertEqual(len(content), Module.objects.count())
+        self.assertEqual(content[-1]["fields"]["vcs_root"], 'git://git.gnome.org/zenity')
+
     def test_branch_methods(self):
         self.assertTrue(self.branch.is_head())
         self.assertEqual(self.branch.get_vcs_url(), "git://git.gnome.org/gnome-hello")
@@ -437,6 +447,23 @@ class UtilsTests(TestCase):
 
 
 class OtherTests(TestCase):
+    def test_release_list(self):
+        Release.objects.bulk_create([
+            Release(name='gnome-3-18', description='GNOME 3.18', status='official', weight=0),
+            Release(name='gnome-2-32', description='GNOME 2.32', status='official', weight=-10),
+        ])
+        response = self.client.get(reverse('releases'))
+        contents = [
+            '<h1>GNOME Releases</h1>', '<h2>Older Releases</h2>',
+            '<a href="%s">GNOME 3.18</a>' % reverse('release', args=['gnome-3-18']),
+        ]
+        for item in contents:
+            self.assertContains(response, item)
+        # Also test JSON output
+        response = self.client.get(reverse('releases', args=['json']))
+        content = json.loads(response.content)
+        self.assertEqual(content[0]["fields"]["name"], "gnome-3-18")
+
     def test_bugzilla_linkify(self):
         from stats.templatetags.stats_extras import bugzilla_linkify
         self.assertEqual(bugzilla_linkify(u"Sample normal text should not be altered."),
diff --git a/stats/views.py b/stats/views.py
index 1b658eb..2a2bed3 100644
--- a/stats/views.py
+++ b/stats/views.py
@@ -40,7 +40,7 @@ def modules(request, format='html'):
     all_modules = Module.objects.all()
     if format in ('json', 'xml'):
         data = serializers.serialize(format, all_modules)
-        return HttpResponse(data, mimetype=MIME_TYPES[format])
+        return HttpResponse(data, content_type=MIME_TYPES[format])
     context = {
         'pageSection':  "module",
         'modules': utils.sort_object_list(all_modules, 'get_description'),
@@ -267,7 +267,7 @@ def releases(request, format='html'):
     if format in ('json', 'xml'):
         from itertools import chain
         data = serializers.serialize(format, chain(active_releases, old_releases))
-        return HttpResponse(data, mimetype=MIME_TYPES[format])
+        return HttpResponse(data, content_type=MIME_TYPES[format])
     context = {
         'pageSection'    : "releases",
         'active_releases': active_releases,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]