Code Duplication    Length = 48-48 lines in 2 locations

django-data/image/biosample/tests/test_submit.py 1 location

@@ 418-465 (lines=48) @@
415
# --- submission owenership
416
417
418
class ErrorSubmitViewtest(TestMixin, TestCase):
419
    """A class to test submission not belonging to the user or which doesn't
420
    exists"""
421
422
    @patch('biosample.views.SplitSubmissionTask.delay')
423
    def setUp(self, my_submit):
424
        self.client = Client()
425
        self.client.login(username='test2', password='test2')
426
427
        # get a submission object
428
        submission = Submission.objects.get(pk=1)
429
430
        # set a status which I can ready
431
        submission.status = READY
432
        submission.save()
433
434
        # track submission ID
435
        self.submission_id = submission.id
436
437
        # get the url for dashboard
438
        self.url = reverse('biosample:submit')
439
440
        # track my patched function
441
        self.my_submit = my_submit
442
443
    def test_ownership(self):
444
        """Test a non-owner having a 404 response"""
445
446
        response = self.client.post(
447
            self.url, {
448
                'submission_id': self.submission_id
449
            }
450
        )
451
452
        self.assertEqual(response.status_code, 404)
453
        self.assertFalse(self.my_submit.called)
454
455
    def test_does_not_exists(self):
456
        """Test a submission which doesn't exists"""
457
458
        response = self.client.post(
459
            self.url, {
460
                'submission_id': 99
461
            }
462
        )
463
464
        self.assertEqual(response.status_code, 404)
465
        self.assertFalse(self.my_submit.called)
466

django-data/image/validation/tests/test_views.py 1 location

@@ 229-276 (lines=48) @@
226
        self.assertFalse(self.my_validation.called)
227
228
229
class ErrorValidateViewtest(TestMixin, TestCase):
230
    """A class to test submission not belonging to the user or which doesn't
231
    exists"""
232
233
    @patch('validation.views.ValidateTask.delay')
234
    def setUp(self, my_validation):
235
        self.client = Client()
236
        self.client.login(username='test2', password='test2')
237
238
        # get a submission object
239
        submission = Submission.objects.get(pk=1)
240
241
        # set a status which I can validate
242
        submission.status = LOADED
243
        submission.save()
244
245
        # track submission ID
246
        self.submission_id = submission.id
247
248
        # get the url for dashboard
249
        self.url = reverse('validation:validate')
250
251
        # track my patched function
252
        self.my_validation = my_validation
253
254
    def test_ownership(self):
255
        """Test a non-owner having a 404 response"""
256
257
        response = self.client.post(
258
            self.url, {
259
                'submission_id': self.submission_id
260
            }
261
        )
262
263
        self.assertEqual(response.status_code, 404)
264
        self.assertFalse(self.my_validation.called)
265
266
    def test_does_not_exists(self):
267
        """Test a submission which doesn't exists"""
268
269
        response = self.client.post(
270
            self.url, {
271
                'submission_id': 99
272
            }
273
        )
274
275
        self.assertEqual(response.status_code, 404)
276
        self.assertFalse(self.my_validation.called)
277