Commit 7398c9c0f7835084414f2aa3f9245bdde6c3f912
1 parent
fa1287f9
Exists in
master
and in
3 other branches
Fixed flake8 warnings
Signed-off-by: Macartur Sousa <macartur.sc@gmail.com> Signed-off-by: Carlos Oliveira <carlospecter@gmail.com>
Showing
3 changed files
with
27 additions
and
25 deletions
Show diff stats
colab_spb/tests/test_get_list.py
1 | -from django.http import HttpResponsePermanentRedirect | 1 | +# -*- coding: utf-8 -*- |
2 | from django.test import TestCase, Client | 2 | from django.test import TestCase, Client |
3 | 3 | ||
4 | -from colab.super_archives.models import * | ||
5 | 4 | ||
6 | class ColabSPB(TestCase): | 5 | class ColabSPB(TestCase): |
7 | 6 | ||
@@ -16,17 +15,20 @@ class ColabSPB(TestCase): | @@ -16,17 +15,20 @@ class ColabSPB(TestCase): | ||
16 | 15 | ||
17 | def test_getlist_without_list(self): | 16 | def test_getlist_without_list(self): |
18 | response = self.client.get("/spb/get_list/?list_name=") | 17 | response = self.client.get("/spb/get_list/?list_name=") |
19 | - self.assertEqual("",response.content) | ||
20 | - self.assertEqual(404,response.status_code) | 18 | + message = ("Não foi encontrada lista de discussão a está" |
19 | + " comunidade, para mais detalhes contacte o" | ||
20 | + " administrador.") | ||
21 | + self.assertEqual(message, response.content) | ||
22 | + self.assertEqual(404, response.status_code) | ||
21 | 23 | ||
22 | def test_getlist_with_list(self): | 24 | def test_getlist_with_list(self): |
23 | response = self.client.get("/spb/get_list/?list_name=ListA&MAX=5") | 25 | response = self.client.get("/spb/get_list/?list_name=ListA&MAX=5") |
24 | - self.assertEqual(5,len(response.context[1]['latest'])) | 26 | + self.assertEqual(5, len(response.context[1]['latest'])) |
25 | 27 | ||
26 | def test_getlist_default_MAX(self): | 28 | def test_getlist_default_MAX(self): |
27 | response = self.client.get("/spb/get_list/?list_name=ListA") | 29 | response = self.client.get("/spb/get_list/?list_name=ListA") |
28 | - self.assertEqual(7,len(response.context[1]['latest'])) | 30 | + self.assertEqual(7, len(response.context[1]['latest'])) |
29 | 31 | ||
30 | def test_getlist_invalid_MAX(self): | 32 | def test_getlist_invalid_MAX(self): |
31 | response = self.client.get("/spb/get_list/?list_name=ListA&MAX=") | 33 | response = self.client.get("/spb/get_list/?list_name=ListA&MAX=") |
32 | - self.assertEqual(7,len(response.context[1]['latest'])) | 34 | + self.assertEqual(7, len(response.context[1]['latest'])) |
colab_spb/urls.py
@@ -2,6 +2,6 @@ from django.conf.urls import patterns, url | @@ -2,6 +2,6 @@ from django.conf.urls import patterns, url | ||
2 | from . import views | 2 | from . import views |
3 | 3 | ||
4 | urlpatterns = patterns('', | 4 | urlpatterns = patterns('', |
5 | - url( r'^get_list/$',views.get_list, name='get_list'), | ||
6 | - url( r'^feed_repository/$',views.feed_repository, name='feed_repository'), | ||
7 | -) | 5 | + url(r'^get_list/$', views.get_list, name='get_list'), |
6 | + url(r'^feed_repository/$', views.feed_repository, | ||
7 | + name='feed_repository'), ) |
colab_spb/views.py
1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
2 | from django.shortcuts import render | 2 | from django.shortcuts import render |
3 | from django.http import HttpResponse | 3 | from django.http import HttpResponse |
4 | -from django.utils.translation import ugettext as _ | ||
5 | from colab.super_archives.models import MailingList, Thread | 4 | from colab.super_archives.models import MailingList, Thread |
6 | from colab.accounts.utils import mailman | 5 | from colab.accounts.utils import mailman |
7 | from colab.accounts.models import User | 6 | from colab.accounts.models import User |
8 | 7 | ||
9 | -def get_list(request): | ||
10 | 8 | ||
11 | - list_name = request.GET.get('list_name',None) | ||
12 | - MAX = request.GET.get('MAX',7) | 9 | +def get_list(request): |
10 | + list_name = request.GET.get('list_name', None) | ||
11 | + MAX = request.GET.get('MAX', 7) | ||
13 | 12 | ||
14 | if not MAX: | 13 | if not MAX: |
15 | MAX = 7 | 14 | MAX = 7 |
@@ -42,26 +41,27 @@ def get_list(request): | @@ -42,26 +41,27 @@ def get_list(request): | ||
42 | )) | 41 | )) |
43 | 42 | ||
44 | if len(context['lists']) == 0: | 43 | if len(context['lists']) == 0: |
45 | - return HttpResponse("""Não foi encontrada lista de discussão a está | ||
46 | - comunidade, para mais detalhes contacte o | ||
47 | - administrador.""",status=404) | 44 | + message = ("Não foi encontrada lista de discussão a está" |
45 | + " comunidade, para mais detalhes contacte o" | ||
46 | + " administrador.") | ||
47 | + return HttpResponse(message, status=404) | ||
48 | 48 | ||
49 | - return render(request,"discussion.html",context) | 49 | + return render(request, "discussion.html", context) |
50 | 50 | ||
51 | 51 | ||
52 | def feed_repository(request): | 52 | def feed_repository(request): |
53 | - group = request.GET.get('group',"") | ||
54 | - project = request.GET.get('project',"") | ||
55 | - limit = request.GET.get("limit",20) | 53 | + group = request.GET.get('group', "") |
54 | + project = request.GET.get('project', "") | ||
55 | + limit = request.GET.get("limit", 20) | ||
56 | 56 | ||
57 | context = {} | 57 | context = {} |
58 | - context['url']= '/gitlab' | 58 | + context['url'] = '/gitlab' |
59 | 59 | ||
60 | - if group : | 60 | + if group: |
61 | context['url'] += "/"+group | 61 | context['url'] += "/"+group |
62 | - if project : | 62 | + if project: |
63 | context['url'] += "/"+project | 63 | context['url'] += "/"+project |
64 | if limit: | 64 | if limit: |
65 | context['limit'] = limit | 65 | context['limit'] = limit |
66 | 66 | ||
67 | - return render(request,"feed_repository.html",context) | 67 | + return render(request, "feed_repository.html", context) |