Code Duplication    Length = 38-38 lines in 2 locations

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

@@ 974-1011 (lines=38) @@
971
        # calling a WebSocketMixin method
972
        self.check_message(message, notification_message)
973
974
    def test_error_in_draft_status(self):
975
        # a still running submission
976
        self.my_submission = Mock()
977
        self.my_submission.name = "test-fetch"
978
        self.my_submission.status = 'Draft'
979
980
        # assert task and mock methods called
981
        self.common_tests(self.my_submission)
982
983
        # test email sent
984
        self.assertEqual(len(mail.outbox), 1)
985
986
        # read email
987
        email = mail.outbox[0]
988
989
        self.assertEqual(
990
            "Error in biosample submission %s" % self.submission_obj_id,
991
            email.subject)
992
993
        # check submission.state changed
994
        self.submission_obj.refresh_from_db()
995
996
        self.assertEqual(self.submission_obj.status, ERROR)
997
        self.assertIn(
998
            "Biosample subission {} remained with the same status".format(
999
                    self.submission_obj),
1000
            self.submission_obj.message
1001
            )
1002
1003
        message = 'Error'
1004
        notification_message = (
1005
            'Biosample subission Cryoweb '
1006
            '(United Kingdom, test) remained with the '
1007
            'same status for more than 5 days. Please '
1008
            'report it to InjectTool team')
1009
1010
        # calling a WebSocketMixin method
1011
        self.check_message(message, notification_message)
1012
1013
1014
class FetchUnsupportedStatusTestCase(FetchMixin, TestCase):
@@ 935-972 (lines=38) @@
932
            self.submission_obj.updated_at = testtime
933
            self.submission_obj.save()
934
935
    def test_error_in_submitted_status(self):
936
        # a still running submission
937
        self.my_submission = Mock()
938
        self.my_submission.name = "test-fetch"
939
        self.my_submission.status = 'Submitted'
940
941
        # assert task and mock methods called
942
        self.common_tests(self.my_submission)
943
944
        # test email sent
945
        self.assertEqual(len(mail.outbox), 1)
946
947
        # read email
948
        email = mail.outbox[0]
949
950
        self.assertEqual(
951
            "Error in biosample submission %s" % self.submission_obj_id,
952
            email.subject)
953
954
        # check submission.state changed
955
        self.submission_obj.refresh_from_db()
956
957
        self.assertEqual(self.submission_obj.status, ERROR)
958
        self.assertIn(
959
            "Biosample subission {} remained with the same status".format(
960
                    self.submission_obj),
961
            self.submission_obj.message
962
            )
963
964
        message = 'Error'
965
        notification_message = (
966
            'Biosample subission Cryoweb '
967
            '(United Kingdom, test) remained with the '
968
            'same status for more than 5 days. Please '
969
            'report it to InjectTool team')
970
971
        # calling a WebSocketMixin method
972
        self.check_message(message, notification_message)
973
974
    def test_error_in_draft_status(self):
975
        # a still running submission