def test_get_decline_reasons_timeout_error(self, mock_get):
        mock_get.side_effect = Timeout(self.error_msg)

        with self.assertRaises(ApplicationError) as context:
            verification_api = VerificationAPI()
            verification_api.get_decline_reasons()

        self.assertEqual(
            context.exception.message,
            'Connection to verification_api timed out: {}'.format(
                self.error_msg))
        self.assertEqual(context.exception.code, 'E403')
        self.assertEqual(context.exception.http_code, 500)
    def test_get_decline_reasons_http_error(self, mock_get):
        mock_get.side_effect = HTTPError(self.error_msg)

        with self.assertRaises(ApplicationError) as context:
            verification_api = VerificationAPI()
            verification_api.get_decline_reasons()

        self.assertEqual(
            context.exception.message,
            'Received the following response from verification_api: {}'.format(
                self.error_msg))
        self.assertEqual(context.exception.code, 'E401')
        self.assertEqual(context.exception.http_code, 500)
    def test_get_decline_reasons_connection_error(self, mock_get):
        mock_get.side_effect = ConnectionError(self.error_msg)

        with self.assertRaises(ApplicationError) as context:
            verification_api = VerificationAPI()
            verification_api.get_decline_reasons()

        self.assertEqual(
            context.exception.message,
            'Encountered an error connecting to verification_api: {}'.format(
                self.error_msg))
        self.assertEqual(context.exception.code, 'E402')
        self.assertEqual(context.exception.http_code, 500)
    def test_get_decline_reasons(self, mock_get):
        mock_get.return_value.json.return_value = [{
            'decline_reason':
            'test',
            'decline_text':
            'This is a test decline reason'
        }]
        mock_get.return_value.status_code = 200

        verification_api = VerificationAPI()
        response = verification_api.get_decline_reasons()

        self.assertEqual(response,
                         [{
                             'decline_reason': 'test',
                             'decline_text': 'This is a test decline reason'
                         }])