예제 #1
0
    def test_update_table_spec(self):
        # Setup Expected Response
        name = "name3373707"
        time_column_spec_id = "timeColumnSpecId1558734824"
        row_count = 1340416618
        column_count = 122671386
        etag = "etag3123477"
        expected_response = {
            "name": name,
            "time_column_spec_id": time_column_spec_id,
            "row_count": row_count,
            "column_count": column_count,
            "etag": etag,
        }
        expected_response = table_spec_pb2.TableSpec(**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
        table_spec = {}

        response = client.update_table_spec(table_spec)
        assert expected_response == response

        assert len(channel.requests) == 1
        expected_request = service_pb2.UpdateTableSpecRequest(table_spec=table_spec)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
예제 #2
0
    def test_get_table_spec(self):
        # Setup Expected Response
        name_2 = "name2-1052831874"
        time_column_spec_id = "timeColumnSpecId1558734824"
        row_count = 1340416618
        column_count = 122671386
        etag = "etag3123477"
        expected_response = {
            "name": name_2,
            "time_column_spec_id": time_column_spec_id,
            "row_count": row_count,
            "column_count": column_count,
            "etag": etag,
        }
        expected_response = table_spec_pb2.TableSpec(**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.table_spec_path(
            "[PROJECT]", "[LOCATION]", "[DATASET]", "[TABLE_SPEC]"
        )

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

        assert len(channel.requests) == 1
        expected_request = service_pb2.GetTableSpecRequest(name=name)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
예제 #3
0
    def test_get_table_spec(self):
        # Setup Expected Response
        name_2 = 'name2-1052831874'
        time_column_spec_id = 'timeColumnSpecId1558734824'
        row_count = 1340416618
        column_count = 122671386
        etag = 'etag3123477'
        expected_response = {
            'name': name_2,
            'time_column_spec_id': time_column_spec_id,
            'row_count': row_count,
            'column_count': column_count,
            'etag': etag
        }
        expected_response = table_spec_pb2.TableSpec(**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.table_spec_path('[PROJECT]', '[LOCATION]', '[DATASET]',
                                      '[TABLE_SPEC]')

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

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