Code Duplication    Length = 11-12 lines in 3 locations

tests/test_tpm.py 3 locations

@@ 1018-1029 (lines=12) @@
1015
        error_json={'error': 'not good', 'message': exception_error}
1016
        path_to_mock = 'passwords/json_error.json'
1017
        request_url = api_url + path_to_mock
1018
        with self.assertRaises(tpm.TPMException) as context:
1019
            with requests_mock.Mocker() as m:
1020
                m.get(request_url, json=error_json)
1021
                response = self.client.show_password('json_error')
1022
        log.debug("context exception: {}".format(context.exception))
1023
        self.assertTrue(exception_error in str(context.exception))
1024
1025
    def test_exception_on_403(self):
1026
        """Exception if 403 forbidden."""
1027
        path_to_mock = 'passwords.json'
1028
        request_url = api_url + path_to_mock
1029
        exception_error = "{} forbidden".format(request_url)
1030
        with self.assertRaises(tpm.TPMException) as context:
1031
            with requests_mock.Mocker() as m:
1032
                m.get(request_url, text='forbidden', status_code=403)
@@ 1055-1065 (lines=11) @@
1052
        request_url = api_url + path_to_mock
1053
        exception_error = "{} Method Not Allowed".format(request_url)
1054
        with self.assertRaises(ValueError) as context:
1055
            with requests_mock.Mocker() as m:
1056
                m.get(request_url, text='Method Not Allowed', status_code=405)
1057
                response = self.client.list_passwords()
1058
        log.debug("context exception: {}".format(context.exception))
1059
        self.assertTrue(str(context.exception).endswith(exception_error))
1060
@@ 1043-1053 (lines=11) @@
1040
        request_url = api_url + path_to_mock
1041
        exception_error = "{} not found".format(request_url)
1042
        with self.assertRaises(tpm.TPMException) as context:
1043
            with requests_mock.Mocker() as m:
1044
                m.get(request_url, text='not found', status_code=404)
1045
                response = self.client.list_passwords()
1046
        log.debug("context exception: {}".format(context.exception))
1047
        self.assertTrue(exception_error in str(context.exception))
1048
1049
    def test_exception_on_405(self):
1050
        """Exception if 405 Method Not Allowed."""
1051
        path_to_mock = 'passwords.json'
1052
        request_url = api_url + path_to_mock
1053
        exception_error = "{} Method Not Allowed".format(request_url)
1054
        with self.assertRaises(ValueError) as context:
1055
            with requests_mock.Mocker() as m:
1056
                m.get(request_url, text='Method Not Allowed', status_code=405)