|
1 | 1 | # -*- coding: utf-8 -*-
|
2 | 2 | import hashlib
|
3 | 3 | import json
|
| 4 | +import uuid |
4 | 5 |
|
5 | 6 | from django.conf import settings
|
6 | 7 | from django.core.urlresolvers import reverse
|
@@ -222,31 +223,34 @@ def test_upload_does_not_exist(self):
|
222 | 223 | eq_(response.json, {u'upload': [u'No upload found.']})
|
223 | 224 |
|
224 | 225 | def test_dont_own_the_upload(self):
|
225 |
| - FileUpload.objects.create(uuid='my-uuid', user=None, valid=True) |
| 226 | + myid = uuid.uuid4().hex |
| 227 | + FileUpload.objects.create(uuid=myid, user=None, valid=True) |
226 | 228 | self.grant_permission(self.user, 'LangPacks:Admin')
|
227 | 229 |
|
228 | 230 | response = self.client.post(self.list_url, data=json.dumps({
|
229 |
| - 'upload': 'my-uuid'})) |
| 231 | + 'upload': myid})) |
230 | 232 | eq_(response.status_code, 400)
|
231 | 233 | eq_(response.json, {u'upload': [u'No upload found.']})
|
232 | 234 |
|
233 | 235 | def test_invalid_upload(self):
|
234 |
| - FileUpload.objects.create(uuid='my-uuid', valid=False, user=self.user) |
| 236 | + myid = uuid.uuid4().hex |
| 237 | + FileUpload.objects.create(uuid=myid, valid=False, user=self.user) |
235 | 238 | self.grant_permission(self.user, 'LangPacks:Admin')
|
236 | 239 |
|
237 | 240 | response = self.client.post(self.list_url, data=json.dumps({
|
238 |
| - 'upload': 'my-uuid'})) |
| 241 | + 'upload': myid})) |
239 | 242 | eq_(response.status_code, 400)
|
240 | 243 | eq_(response.json, {u'upload': [u'Upload not valid.']})
|
241 | 244 |
|
242 | 245 | @patch('mkt.langpacks.models.LangPack.from_upload')
|
243 | 246 | def test_errors_returned_by_from_upload(self, mock_from_upload):
|
244 | 247 | mock_from_upload.side_effect = ValidationError('foo bar')
|
245 |
| - FileUpload.objects.create(uuid='my-uuid', valid=True, user=self.user) |
| 248 | + myid = uuid.uuid4().hex |
| 249 | + FileUpload.objects.create(uuid=myid, valid=True, user=self.user) |
246 | 250 | self.grant_permission(self.user, 'LangPacks:Admin')
|
247 | 251 |
|
248 | 252 | response = self.client.post(self.list_url, data=json.dumps({
|
249 |
| - 'upload': 'my-uuid'})) |
| 253 | + 'upload': myid})) |
250 | 254 | eq_(response.status_code, 400)
|
251 | 255 | eq_(response.json, {u'detail': [u'foo bar']})
|
252 | 256 |
|
@@ -336,31 +340,34 @@ def test_upload_does_not_exist(self):
|
336 | 340 | eq_(response.json, {u'upload': [u'No upload found.']})
|
337 | 341 |
|
338 | 342 | def test_dont_own_the_upload(self):
|
339 |
| - FileUpload.objects.create(uuid='my-uuid', user=None, valid=True) |
| 343 | + myid = uuid.uuid4().hex |
| 344 | + FileUpload.objects.create(uuid=myid, user=None, valid=True) |
340 | 345 | self.grant_permission(self.user, 'LangPacks:Admin')
|
341 | 346 |
|
342 | 347 | response = self.client.put(self.detail_url, data=json.dumps({
|
343 |
| - 'upload': 'my-uuid'})) |
| 348 | + 'upload': myid})) |
344 | 349 | eq_(response.status_code, 400)
|
345 | 350 | eq_(response.json, {u'upload': [u'No upload found.']})
|
346 | 351 |
|
347 | 352 | def test_invalid_upload(self):
|
348 |
| - FileUpload.objects.create(uuid='my-uuid', valid=False, user=self.user) |
| 353 | + myid = uuid.uuid4().hex |
| 354 | + FileUpload.objects.create(uuid=myid, valid=False, user=self.user) |
349 | 355 | self.grant_permission(self.user, 'LangPacks:Admin')
|
350 | 356 |
|
351 | 357 | response = self.client.put(self.detail_url, data=json.dumps({
|
352 |
| - 'upload': 'my-uuid'})) |
| 358 | + 'upload': myid})) |
353 | 359 | eq_(response.status_code, 400)
|
354 | 360 | eq_(response.json, {u'upload': [u'Upload not valid.']})
|
355 | 361 |
|
356 | 362 | @patch('mkt.langpacks.models.LangPack.from_upload')
|
357 | 363 | def test_errors_returned_by_from_upload(self, mock_from_upload):
|
358 | 364 | mock_from_upload.side_effect = ValidationError('foo bar')
|
359 |
| - FileUpload.objects.create(uuid='my-uuid', valid=True, user=self.user) |
| 365 | + myid = uuid.uuid4().hex |
| 366 | + FileUpload.objects.create(uuid=myid, valid=True, user=self.user) |
360 | 367 | self.grant_permission(self.user, 'LangPacks:Admin')
|
361 | 368 |
|
362 | 369 | response = self.client.put(self.detail_url, data=json.dumps({
|
363 |
| - 'upload': 'my-uuid'})) |
| 370 | + 'upload': myid})) |
364 | 371 | eq_(response.status_code, 400)
|
365 | 372 | eq_(response.json, {u'detail': [u'foo bar']})
|
366 | 373 |
|
|
0 commit comments