@@ -0,0 +1,2598 @@
+# Copyright 2021 Google LLC%0A#%0A# Licensed under the Apache License, Version 2.0 (the %22License%22);%0A# you may not use this file except in compliance with the License.%0A# You may obtain a copy of the License at%0A#%0A#     https://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A%0Aimport pytest%0Afrom google import showcase%0Afrom google.rpc import error_details_pb2%0Afrom google.protobuf import any_pb2%0Afrom grpc_status import rpc_status%0Afrom google.api_core import exceptions%0A%0A%0Adef create_status(error_details=None):%0A    status = rpc_status.status_pb2.Status()%0A    status.code = 3%0A    status.message = (%0A        %22test%22%0A    )%0A    status_detail = any_pb2.Any()%0A    if error_details:%0A        status_detail.Pack(error_details)%0A    status.details.append(status_detail)%0A    return status%0A%0A%0Adef test_bad_request_details(echo):%0A    def create_bad_request_details():%0A        bad_request_details = error_details_pb2.BadRequest()%0A        field_violation = bad_request_details.field_violations.add()%0A        field_violation.field = %22test field%22%0A        field_violation.description = %22test description%22%0A        return bad_request_details%0A    bad_request_details = create_bad_request_details()%0A    status = create_status(bad_request_details)%0A%0A    with pytest.raises(exceptions.GoogleAPICallError) as e:%0A        _ = echo.echo(showcase.EchoRequest(%0A            error=status,%0A        ))%0A        assert e.details == %5Bbad_request_details%5D%0A%0A%0Adef test_precondition_failure_details(echo):%0A    def create_precondition_failure_details():%0A        pf_details = error_details_pb2.PreconditionFailure()%0A        violation = pf_details.violations.add()%0A        violation.type = %22test type%22%0A        violation.subject = %22test subject%22%0A        violation.description = %22test description%22%0A        return pf_details%0A%0A    pf_details = create_precondition_failure_details()%0A    status = create_status(pf_details)%0A%0A    with pytest.raises(exceptions.GoogleAPICallError) as e:%0A        _ = echo.echo(showcase.EchoRequest(%0A            error=status,%0A        ))%0A        assert e.details == %5Bpf_details%5D%0A%0A%0Adef test_unknown_details(echo):%0A    status = create_status()%0A    with pytest.raises(exceptions.GoogleAPICallError) as e:%0A        _ = echo.echo(showcase.EchoRequest(%0A            error=status,%0A        ))%0A        assert e.details == status.details%0A

add system tests to check error details (#1076)