Exemplo n.º 1
0
def test_that_parse_data_works_properly():
    from google.cloud.bigquery.table import Row
    test_schema = {'fields': [
        {'mode': 'NULLABLE', 'name': 'column_x', 'type': 'STRING'}]}
    field_to_index = {'column_x': 0}
    values = ('row_value',)
    test_page = [Row(values, field_to_index)]

    test_output = gbq._parse_data(test_schema, test_page)
    correct_output = DataFrame({'column_x': ['row_value']})
    tm.assert_frame_equal(test_output, correct_output)
Exemplo n.º 2
0
def test_that_parse_data_works_properly():
    from google.cloud.bigquery.table import Row

    test_schema = {
        "fields": [{
            "mode": "NULLABLE",
            "name": "column_x",
            "type": "STRING"
        }]
    }
    field_to_index = {"column_x": 0}
    values = ("row_value", )
    test_page = [Row(values, field_to_index)]

    test_output = gbq._parse_data(test_schema, test_page)
    correct_output = DataFrame({"column_x": ["row_value"]})
    tm.assert_frame_equal(test_output, correct_output)
Exemplo n.º 3
0
def test_should_return_bigquery_correctly_typed(input, type_, expected):
    result = gbq._parse_data(
        dict(fields=[dict(name="x", type=type_, mode="NULLABLE")]),
        rows=[[input]],
    ).iloc[0, 0]
    assert result == expected