def test_perform_search_http_error(self, mock_post):
        mock_post.side_effect = HTTPError(self.error_msg)

        with self.assertRaises(ApplicationError) as context:
            search_entries = {
                "first_name": "test",
                "last_name": "",
                "organisation_name": "",
                "email": "",
            }

            verification_api = VerificationAPI()
            verification_api.perform_search(search_entries)

        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)
        self.assertEqual(mock_post.call_count, 1)
    def test_perform_search_timeout_error(self, mock_post):
        mock_post.side_effect = Timeout(self.error_msg)

        with self.assertRaises(ApplicationError) as context:
            search_entries = {
                "first_name": "test",
                "last_name": "",
                "organisation_name": "",
                "email": "",
            }

            verification_api = VerificationAPI()
            verification_api.perform_search(search_entries)

        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)
        self.assertEqual(mock_post.call_count, 1)
    def test_perform_search(self, mock_post):
        mock_post.return_value.json.return_value = [{'case_id': 1}]
        mock_post.return_value.status_code = 200

        search_entries = {
            "first_name": "test",
            "last_name": "",
            "organisation_name": "",
            "email": "",
        }

        verification_api = VerificationAPI()
        response = verification_api.perform_search(search_entries)

        self.assertEqual(response, [{'case_id': 1}])
        self.assertEqual(mock_post.call_count, 1)