def test_invalid_change_partition_by():
    conf = BQTestKitConfig({DEFAULT_LOCATION: "EU"})
    project = Project("test_project", bq_client=None, bqtk_config=conf)
    ds = Dataset("dataset_foo",
                 project=project,
                 bq_client=None,
                 bqtk_config=conf)
    table = Table("table_bar",
                  from_dataset=ds,
                  bq_client=None,
                  bqtk_config=conf)
    with pytest.raises(Exception):
        table.partition_by("zoo")
def test_change_partition_by():
    conf = BQTestKitConfig({DEFAULT_LOCATION: "EU"})
    project = Project("test_project", bq_client=None, bqtk_config=conf)
    ds = Dataset("dataset_foo",
                 project=project,
                 bq_client=None,
                 bqtk_config=conf)
    table = Table("table_bar",
                  from_dataset=ds,
                  bq_client=None,
                  bqtk_config=conf)
    table = table.partition_by(
        Range(on_field="zoo", start=0, end=10000, interval=10))
    assert isinstance(table.partition_type, Range)
    assert table.partition_type.field == "zoo"
    assert table.partition_type.start == 0
    assert table.partition_type.end == 10000
    assert table.partition_type.interval == 10