Commit 027ebb2bea1e41a9c29789f156b8c41b8803a0b4
1 parent
ba3909bb
Exists in
master
and in
79 other branches
Added Tests and fixing discussion
Signed-off-by: Macartur Sousa <macartur.sc@gmail.com> Signed-off-by: Gust <darksshades@hotmail.com>
Showing
5 changed files
with
384 additions
and
16 deletions
Show diff stats
@@ -0,0 +1,368 @@ | @@ -0,0 +1,368 @@ | ||
1 | +[ | ||
2 | +{ | ||
3 | + "fields": { | ||
4 | + "description": "List A description.", | ||
5 | + "email": "listA@example.com", | ||
6 | + "logo": "", | ||
7 | + "last_imported_index": 0, | ||
8 | + "is_private": false, | ||
9 | + "name": "ListA" | ||
10 | + }, | ||
11 | + "model": "super_archives.mailinglist", | ||
12 | + "pk": 1 | ||
13 | +}, | ||
14 | +{ | ||
15 | + "fields": { | ||
16 | + "description": "List B description.", | ||
17 | + "email": "listB@example.com", | ||
18 | + "logo": "", | ||
19 | + "last_imported_index": 0, | ||
20 | + "is_private": false, | ||
21 | + "name": "ListB" | ||
22 | + }, | ||
23 | + "model": "super_archives.mailinglist", | ||
24 | + "pk": 2 | ||
25 | +}, | ||
26 | +{ | ||
27 | + "fields": { | ||
28 | + "description": "List C description", | ||
29 | + "email": "listC@example.com", | ||
30 | + "logo": "", | ||
31 | + "last_imported_index": 0, | ||
32 | + "is_private": false, | ||
33 | + "name": "ListC" | ||
34 | + }, | ||
35 | + "model": "super_archives.mailinglist", | ||
36 | + "pk": 3 | ||
37 | +}, | ||
38 | +{ | ||
39 | + "fields": { | ||
40 | + "spam": false, | ||
41 | + "subject_token": "Thread_1_on_List_A", | ||
42 | + "mailinglist": 1, | ||
43 | + "score": 31, | ||
44 | + "latest_message": 3 | ||
45 | + }, | ||
46 | + "model": "super_archives.thread", | ||
47 | + "pk": 1 | ||
48 | +}, | ||
49 | +{ | ||
50 | + "fields": { | ||
51 | + "spam": false, | ||
52 | + "subject_token": "Thread_1_on_List_B", | ||
53 | + "mailinglist": 2, | ||
54 | + "score": 0, | ||
55 | + "latest_message": 4 | ||
56 | + }, | ||
57 | + "model": "super_archives.thread", | ||
58 | + "pk": 3 | ||
59 | +}, | ||
60 | +{ | ||
61 | + "fields": { | ||
62 | + "spam": false, | ||
63 | + "subject_token": "Thread_1_on_List_C", | ||
64 | + "mailinglist": 3, | ||
65 | + "score": 0, | ||
66 | + "latest_message": 8 | ||
67 | + }, | ||
68 | + "model": "super_archives.thread", | ||
69 | + "pk": 4 | ||
70 | +}, | ||
71 | +{ | ||
72 | + "fields": { | ||
73 | + "spam": false, | ||
74 | + "subject_token": "Thread_2_on_List_A ", | ||
75 | + "mailinglist": 1, | ||
76 | + "score": 24, | ||
77 | + "latest_message": null | ||
78 | + }, | ||
79 | + "model": "super_archives.thread", | ||
80 | + "pk": 5 | ||
81 | +}, | ||
82 | +{ | ||
83 | + "fields": { | ||
84 | + "spam": false, | ||
85 | + "subject_token": "Thread_3_on_List_A ", | ||
86 | + "mailinglist": 1, | ||
87 | + "score": 24, | ||
88 | + "latest_message": null | ||
89 | + }, | ||
90 | + "model": "super_archives.thread", | ||
91 | + "pk": 6 | ||
92 | +}, | ||
93 | +{ | ||
94 | + "fields": { | ||
95 | + "spam": false, | ||
96 | + "subject_token": "Thread_4_on_List_A ", | ||
97 | + "mailinglist": 1, | ||
98 | + "score": 24, | ||
99 | + "latest_message": null | ||
100 | + }, | ||
101 | + "model": "super_archives.thread", | ||
102 | + "pk": 7 | ||
103 | +}, | ||
104 | +{ | ||
105 | + "fields": { | ||
106 | + "spam": false, | ||
107 | + "subject_token": "Thread_5_on_List_A ", | ||
108 | + "mailinglist": 1, | ||
109 | + "score": 24, | ||
110 | + "latest_message": null | ||
111 | + }, | ||
112 | + "model": "super_archives.thread", | ||
113 | + "pk": 8 | ||
114 | +}, | ||
115 | +{ | ||
116 | + "fields": { | ||
117 | + "spam": false, | ||
118 | + "subject_token": "Thread_6_on_List_A ", | ||
119 | + "mailinglist": 1, | ||
120 | + "score": 24, | ||
121 | + "latest_message": null | ||
122 | + }, | ||
123 | + "model": "super_archives.thread", | ||
124 | + "pk": 9 | ||
125 | +}, | ||
126 | +{ | ||
127 | + "fields": { | ||
128 | + "spam": false, | ||
129 | + "subject_token": "Thread_7_on_List_A ", | ||
130 | + "mailinglist": 1, | ||
131 | + "score": 24, | ||
132 | + "latest_message": null | ||
133 | + }, | ||
134 | + "model": "super_archives.thread", | ||
135 | + "pk": 10 | ||
136 | +}, | ||
137 | +{ | ||
138 | + "fields": { | ||
139 | + "spam": false, | ||
140 | + "subject_token": "Thread_8_on_List_A ", | ||
141 | + "mailinglist": 1, | ||
142 | + "score": 24, | ||
143 | + "latest_message": null | ||
144 | + }, | ||
145 | + "model": "super_archives.thread", | ||
146 | + "pk": 11 | ||
147 | +}, | ||
148 | +{ | ||
149 | + "fields": { | ||
150 | + "body": "This is a repply to Thread 1 on list A", | ||
151 | + "received_time": "2015-01-28T12:43:00.752Z", | ||
152 | + "from_address": 1, | ||
153 | + "thread": 1, | ||
154 | + "spam": false, | ||
155 | + "subject_clean": "Response to Thread 1A", | ||
156 | + "message_id": "response_t1a", | ||
157 | + "subject": "Response to Thread 1A" | ||
158 | + }, | ||
159 | + "model": "super_archives.message", | ||
160 | + "pk": 3 | ||
161 | +}, | ||
162 | +{ | ||
163 | + "fields": { | ||
164 | + "body": "This is a repply to Thread 1 on list B", | ||
165 | + "received_time": "2015-01-28T12:57:22.180Z", | ||
166 | + "from_address": 1, | ||
167 | + "thread": 3, | ||
168 | + "spam": false, | ||
169 | + "subject_clean": "Response to Thread 1B", | ||
170 | + "message_id": "response_t1b", | ||
171 | + "subject": "Message 1 on Thread 1B" | ||
172 | + }, | ||
173 | + "model": "super_archives.message", | ||
174 | + "pk": 4 | ||
175 | +}, | ||
176 | +{ | ||
177 | + "fields": { | ||
178 | + "body": "This is a repply to Thread 1 on list C", | ||
179 | + "received_time": "2015-01-28T13:02:12.903Z", | ||
180 | + "from_address": 1, | ||
181 | + "thread": 4, | ||
182 | + "spam": false, | ||
183 | + "subject_clean": "Response to Thread 1C", | ||
184 | + "message_id": "response_1t1c", | ||
185 | + "subject": "Message 1 on Thread 1C" | ||
186 | + }, | ||
187 | + "model": "super_archives.message", | ||
188 | + "pk": 5 | ||
189 | +}, | ||
190 | +{ | ||
191 | + "fields": { | ||
192 | + "body": "This is a repply to Thread 1 on list C", | ||
193 | + "received_time": "2015-01-28T13:02:12.903Z", | ||
194 | + "from_address": 1, | ||
195 | + "thread": 4, | ||
196 | + "spam": false, | ||
197 | + "subject_clean": "Response 2 to Thread C", | ||
198 | + "message_id": "response_2t1c", | ||
199 | + "subject": "Message 2 to Thread 1C" | ||
200 | + }, | ||
201 | + "model": "super_archives.message", | ||
202 | + "pk": 6 | ||
203 | +}, | ||
204 | +{ | ||
205 | + "fields": { | ||
206 | + "body": "This is a repply to Thread 1 on list C", | ||
207 | + "received_time": "2015-01-28T13:02:12.903Z", | ||
208 | + "from_address": 1, | ||
209 | + "thread": 4, | ||
210 | + "spam": false, | ||
211 | + "subject_clean": "Response 3 to Thread C", | ||
212 | + "message_id": "response_3t1c", | ||
213 | + "subject": "Message 3 to Thread 1C" | ||
214 | + }, | ||
215 | + "model": "super_archives.message", | ||
216 | + "pk": 7 | ||
217 | +}, | ||
218 | +{ | ||
219 | + "fields": { | ||
220 | + "body": "This is a repply to Thread 1 on list C", | ||
221 | + "received_time": "2015-01-28T13:02:12.903Z", | ||
222 | + "from_address": 1, | ||
223 | + "thread": 4, | ||
224 | + "spam": false, | ||
225 | + "subject_clean": "Response 4 to Thread C", | ||
226 | + "message_id": "response_4t1c", | ||
227 | + "subject": "Message 4 to Thread 1C" | ||
228 | + }, | ||
229 | + "model": "super_archives.message", | ||
230 | + "pk": 8 | ||
231 | +}, | ||
232 | +{ | ||
233 | + "fields": { | ||
234 | + "last_name": "Administrator", | ||
235 | + "webpage": "", | ||
236 | + "twitter": "", | ||
237 | + "is_staff": true, | ||
238 | + "user_permissions": [], | ||
239 | + "date_joined": "2015-01-28T12:34:58.770Z", | ||
240 | + "google_talk": "", | ||
241 | + "first_name": "Admin", | ||
242 | + "is_superuser": true, | ||
243 | + "last_login": "2015-01-28T12:35:39.621Z", | ||
244 | + "verification_hash": null, | ||
245 | + "role": "", | ||
246 | + "email": "admin@mail.com", | ||
247 | + "username": "admin", | ||
248 | + "bio": "", | ||
249 | + "needs_update": true, | ||
250 | + "is_active": true, | ||
251 | + "facebook": "", | ||
252 | + "groups": [], | ||
253 | + "password": "pbkdf2_sha256$12000$iiKCMnLZnFJw$UTx89LB8oYTiw9UqkcglzFLmIaZtbr+ZzF1cG3vfcyo=", | ||
254 | + "institution": "", | ||
255 | + "github": "", | ||
256 | + "modified": "2015-01-28T12:45:27.375Z" | ||
257 | + }, | ||
258 | + "model": "accounts.user", | ||
259 | + "pk": 1 | ||
260 | +}, | ||
261 | +{ | ||
262 | + "fields": { | ||
263 | + "last_name": "Norris", | ||
264 | + "webpage": "", | ||
265 | + "twitter": "", | ||
266 | + "is_staff": true, | ||
267 | + "user_permissions": [], | ||
268 | + "date_joined": "2015-01-28T12:34:58.770Z", | ||
269 | + "google_talk": "", | ||
270 | + "first_name": "Chuck", | ||
271 | + "is_superuser": true, | ||
272 | + "last_login": "2015-01-28T12:35:39.621Z", | ||
273 | + "verification_hash": null, | ||
274 | + "role": "", | ||
275 | + "email": "chucknorris@mail.com", | ||
276 | + "username": "chucknorris", | ||
277 | + "bio": "", | ||
278 | + "needs_update": true, | ||
279 | + "is_active": true, | ||
280 | + "facebook": "", | ||
281 | + "groups": [], | ||
282 | + "password": "pbkdf2_sha256$12000$iiKCMnLZnFJw$UTx89LB8oYTiw9UqkcglzFLmIaZtbr+ZzF1cG3vfcyo=", | ||
283 | + "institution": "", | ||
284 | + "github": "", | ||
285 | + "modified": "2015-01-28T12:45:27.375Z" | ||
286 | + }, | ||
287 | + "model": "accounts.user", | ||
288 | + "pk": 2 | ||
289 | +}, | ||
290 | +{ | ||
291 | + "fields": { | ||
292 | + "last_name": "Norris", | ||
293 | + "webpage": "", | ||
294 | + "twitter": "", | ||
295 | + "is_staff": true, | ||
296 | + "user_permissions": [], | ||
297 | + "date_joined": "2015-01-28T12:34:58.770Z", | ||
298 | + "google_talk": "", | ||
299 | + "first_name": "Heisenberg", | ||
300 | + "is_superuser": true, | ||
301 | + "last_login": "2015-01-28T12:35:39.621Z", | ||
302 | + "verification_hash": null, | ||
303 | + "role": "", | ||
304 | + "email": "heisenberg@mail.com", | ||
305 | + "username": "heisenbergnorris", | ||
306 | + "bio": "", | ||
307 | + "needs_update": true, | ||
308 | + "is_active": true, | ||
309 | + "facebook": "", | ||
310 | + "groups": [], | ||
311 | + "password": "pbkdf2_sha256$12000$iiKCMnLZnFJw$UTx89LB8oYTiw9UqkcglzFLmIaZtbr+ZzF1cG3vfcyo=", | ||
312 | + "institution": "", | ||
313 | + "github": "", | ||
314 | + "modified": "2015-01-28T12:45:27.375Z" | ||
315 | + }, | ||
316 | + "model": "accounts.user", | ||
317 | + "pk": 3 | ||
318 | +}, | ||
319 | +{ | ||
320 | + "fields": { | ||
321 | + "last_name": "macartur", | ||
322 | + "webpage": "", | ||
323 | + "twitter": "", | ||
324 | + "is_staff": false, | ||
325 | + "user_permissions": [], | ||
326 | + "date_joined": "2015-08-06T19:23:53Z", | ||
327 | + "google_talk": "", | ||
328 | + "first_name": "macartur", | ||
329 | + "is_superuser": false, | ||
330 | + "last_login": "2015-08-10T19:30:49.564Z", | ||
331 | + "verification_hash": null, | ||
332 | + "role": null, | ||
333 | + "email": "macartur.sc@gmail.com", | ||
334 | + "username": "macartur", | ||
335 | + "bio": null, | ||
336 | + "needs_update": false, | ||
337 | + "is_active": true, | ||
338 | + "facebook": "", | ||
339 | + "groups": [], | ||
340 | + "password": "pbkdf2_sha256$15000$nK2UEWhXi0pK$82RfvAo2pyarmmig8C5rjSq9s5CQihi4myKazIuozj0=", | ||
341 | + "institution": null, | ||
342 | + "github": null, | ||
343 | + "modified": "2015-08-06T19:25:34.683Z" | ||
344 | + }, | ||
345 | + "model": "accounts.user", | ||
346 | + "pk": 4 | ||
347 | +}, | ||
348 | +{ | ||
349 | + "fields": { | ||
350 | + "real_name": "", | ||
351 | + "user": 1, | ||
352 | + "md5": "edb0e96701c209ab4b50211c856c50c4", | ||
353 | + "address": "admin@mail.com" | ||
354 | + }, | ||
355 | + "model": "super_archives.emailaddress", | ||
356 | + "pk": 1 | ||
357 | +}, | ||
358 | +{ | ||
359 | + "fields": { | ||
360 | + "validation_key": "78e8af5ec02c44cba40db50d720b06fc", | ||
361 | + "created": "2015-08-06T19:23:53.473Z", | ||
362 | + "user": 4, | ||
363 | + "address": "macartur.sc@gmail.com" | ||
364 | + }, | ||
365 | + "model": "super_archives.emailaddressvalidation", | ||
366 | + "pk": 1 | ||
367 | +} | ||
368 | +] |
colab_spb/templates/discussion.html
colab_spb/tests/test_get_list.py
@@ -4,7 +4,7 @@ from django.test import TestCase, Client | @@ -4,7 +4,7 @@ from django.test import TestCase, Client | ||
4 | 4 | ||
5 | class ColabSPB(TestCase): | 5 | class ColabSPB(TestCase): |
6 | 6 | ||
7 | - fixtures = ['colab_data.json'] | 7 | + fixtures = ['test_data.json'] |
8 | 8 | ||
9 | def setUp(self): | 9 | def setUp(self): |
10 | super(ColabSPB, self).setUp() | 10 | super(ColabSPB, self).setUp() |
@@ -15,13 +15,13 @@ class ColabSPB(TestCase): | @@ -15,13 +15,13 @@ class ColabSPB(TestCase): | ||
15 | 15 | ||
16 | def test_getlist_without_list(self): | 16 | def test_getlist_without_list(self): |
17 | response = self.client.get("/spb/get_list/?list_name=") | 17 | response = self.client.get("/spb/get_list/?list_name=") |
18 | - self.assertEqual("x",response.content) | 18 | + self.assertEqual("",response.content) |
19 | + self.assertEqual(404,response.status_code) | ||
19 | 20 | ||
20 | def test_getlist_with_list(self): | 21 | def test_getlist_with_list(self): |
21 | response = self.client.get("/spb/get_list/?list_name=ListA&MAX=5") | 22 | response = self.client.get("/spb/get_list/?list_name=ListA&MAX=5") |
22 | - self.assertEqual("x",response.content) | 23 | + self.assertEqual(5,len(response.context[1]['latest'])) |
23 | 24 | ||
24 | def test_getlist_default_MAX(self): | 25 | def test_getlist_default_MAX(self): |
25 | response = self.client.get("/spb/get_list/?list_name=ListA") | 26 | response = self.client.get("/spb/get_list/?list_name=ListA") |
26 | - self.assertEqual("x",response.content) | ||
27 | - | 27 | + self.assertEqual(7,len(response.context[1]['latest'])) |
colab_spb/views.py
1 | from django.shortcuts import render | 1 | from django.shortcuts import render |
2 | +from django.http import HttpResponse | ||
2 | from django.utils.translation import ugettext as _ | 3 | from django.utils.translation import ugettext as _ |
3 | from colab.super_archives.models import MailingList, Thread | 4 | from colab.super_archives.models import MailingList, Thread |
4 | from colab.accounts.utils import mailman | 5 | from colab.accounts.utils import mailman |
5 | from colab.accounts.models import User | 6 | from colab.accounts.models import User |
6 | 7 | ||
7 | def get_list(request): | 8 | def get_list(request): |
8 | - list_name = None | ||
9 | - MAX = 0 | ||
10 | - if request.GET.get('list_name'): | ||
11 | - list_name = request.GET['list_name'] | ||
12 | - if request.GET.get('MAX'): | ||
13 | - MAX = request.GET['MAX'] | 9 | + |
10 | + list_name = request.GET.get('list_name',None) | ||
11 | + MAX = request.GET.get('MAX',7) | ||
14 | 12 | ||
15 | context = {} | 13 | context = {} |
16 | 14 | ||
@@ -39,4 +37,7 @@ def get_list(request): | @@ -39,4 +37,7 @@ def get_list(request): | ||
39 | len(mailman.list_users(list_.name)), | 37 | len(mailman.list_users(list_.name)), |
40 | )) | 38 | )) |
41 | 39 | ||
40 | + if len(context['lists']) == 0: | ||
41 | + return HttpResponse('',status=404) | ||
42 | + | ||
42 | return render(request,"discussion.html",context) | 43 | return render(request,"discussion.html",context) |
tests/settings.py
@@ -31,7 +31,8 @@ LOGGING = { | @@ -31,7 +31,8 @@ LOGGING = { | ||
31 | 31 | ||
32 | HAYSTACK_CONNECTIONS = { | 32 | HAYSTACK_CONNECTIONS = { |
33 | 'default': { | 33 | 'default': { |
34 | - 'ENGINE': 'haystack.backends.solr_backend.SolrEngine', | ||
35 | - 'URL': 'http://127.0.0.1:8983/solr' | ||
36 | - }, | 34 | + 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', |
35 | + 'PATH': os.path.join(BASE_DIR, 'whoosh_index'), | ||
36 | + } | ||
37 | } | 37 | } |
38 | + |