Code Duplication    Length = 38-38 lines in 2 locations

django-data/image/biosample/tests/test_tasks_retrieval.py 2 locations

@@ 494-531 (lines=38) @@
491
        # calling a WebSocketMixin method
492
        self.check_message(message, notification_message)
493
494
    def test_error_in_draft_status(self):
495
        # a still running submission
496
        self.my_submission = Mock()
497
        self.my_submission.name = "test-fetch"
498
        self.my_submission.status = 'Draft'
499
500
        # assert task and mock methods called
501
        self.common_tests(self.my_submission)
502
503
        # test email sent
504
        self.assertEqual(len(mail.outbox), 1)
505
506
        # read email
507
        email = mail.outbox[0]
508
509
        self.assertEqual(
510
            "Error in biosample submission %s" % self.submission_obj_id,
511
            email.subject)
512
513
        # check submission.state changed
514
        self.submission_obj.refresh_from_db()
515
516
        self.assertEqual(self.submission_obj.status, ERROR)
517
        self.assertIn(
518
            "Biosample subission {} remained with the same status".format(
519
                    self.submission_obj),
520
            self.submission_obj.message
521
            )
522
523
        message = 'Error'
524
        notification_message = (
525
            'Biosample subission Cryoweb '
526
            '(United Kingdom, test) remained with the '
527
            'same status for more than 5 days. Please '
528
            'report it to InjectTool team')
529
530
        # calling a WebSocketMixin method
531
        self.check_message(message, notification_message)
532
533
534
class FetchUnsupportedStatusTestCase(FetchMixin, TestCase):
@@ 455-492 (lines=38) @@
452
            self.submission_obj.updated_at = testtime
453
            self.submission_obj.save()
454
455
    def test_error_in_submitted_status(self):
456
        # a still running submission
457
        self.my_submission = Mock()
458
        self.my_submission.name = "test-fetch"
459
        self.my_submission.status = 'Submitted'
460
461
        # assert task and mock methods called
462
        self.common_tests(self.my_submission)
463
464
        # test email sent
465
        self.assertEqual(len(mail.outbox), 1)
466
467
        # read email
468
        email = mail.outbox[0]
469
470
        self.assertEqual(
471
            "Error in biosample submission %s" % self.submission_obj_id,
472
            email.subject)
473
474
        # check submission.state changed
475
        self.submission_obj.refresh_from_db()
476
477
        self.assertEqual(self.submission_obj.status, ERROR)
478
        self.assertIn(
479
            "Biosample subission {} remained with the same status".format(
480
                    self.submission_obj),
481
            self.submission_obj.message
482
            )
483
484
        message = 'Error'
485
        notification_message = (
486
            'Biosample subission Cryoweb '
487
            '(United Kingdom, test) remained with the '
488
            'same status for more than 5 days. Please '
489
            'report it to InjectTool team')
490
491
        # calling a WebSocketMixin method
492
        self.check_message(message, notification_message)
493
494
    def test_error_in_draft_status(self):
495
        # a still running submission