def test_get_glossary(self):
        # Setup Expected Response
        name_2 = "name2-1052831874"
        entry_count = 811131134
        expected_response = {"name": name_2, "entry_count": entry_count}
        expected_response = translation_service_pb2.Glossary(
            **expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = translate_v3beta1.TranslationServiceClient()

        # Setup Request
        name = client.glossary_path("[PROJECT]", "[LOCATION]", "[GLOSSARY]")

        response = client.get_glossary(name)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = translation_service_pb2.GetGlossaryRequest(
            name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_create_glossary(self):
        # Setup Expected Response
        name = "name3373707"
        entry_count = 811131134
        expected_response = {"name": name, "entry_count": entry_count}
        expected_response = translation_service_pb2.Glossary(
            **expected_response)
        operation = operations_pb2.Operation(
            name="operations/test_create_glossary", done=True)
        operation.response.Pack(expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[operation])
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = translate_v3beta1.TranslationServiceClient()

        # Setup Request
        parent = client.location_path("[PROJECT]", "[LOCATION]")
        glossary = {}

        response = client.create_glossary(parent, glossary)
        result = response.result()
        assert expected_response == result

        assert len(channel.requests) == 1
        expected_request = translation_service_pb2.CreateGlossaryRequest(
            parent=parent, glossary=glossary)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request