Exemplo n.º 1
0
    def test_update_column_spec(self):
        # Setup Expected Response
        name = "name3373707"
        display_name = "displayName1615086568"
        etag = "etag3123477"
        expected_response = {"name": name, "display_name": display_name, "etag": etag}
        expected_response = column_spec_pb2.ColumnSpec(**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 = automl_v1beta1.AutoMlClient()

        # Setup Request
        column_spec = {}

        response = client.update_column_spec(column_spec)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = service_pb2.UpdateColumnSpecRequest(column_spec=column_spec)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
Exemplo n.º 2
0
    def test_get_column_spec(self):
        # Setup Expected Response
        name_2 = "name2-1052831874"
        display_name = "displayName1615086568"
        etag = "etag3123477"
        expected_response = {"name": name_2, "display_name": display_name, "etag": etag}
        expected_response = column_spec_pb2.ColumnSpec(**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 = automl_v1beta1.AutoMlClient()

        # Setup Request
        name = client.column_spec_path(
            "[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]", "[COLUMN_SPEC]"
        )

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

        assert len(channel.requests) == 1
        expected_request = service_pb2.GetColumnSpecRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request