def test_full_constructor():
    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)
    schema = [SchemaField("f1", field_type="INT64")]
    table = Table("table_bar",
                  from_dataset=ds,
                  alias="bar",
                  bq_client=None,
                  bqtk_config=conf,
                  resource_strategy=Noop(),
                  isolate_with=lambda x: x.name + "bar",
                  partition_type=IngestionTime(),
                  schema=schema,
                  exists_ok=True)
    assert table.dataset.project.name == "test_project"
    assert table.dataset.name == "dataset_foo"
    assert table.name == "table_bar"
    assert isinstance(table.resource_strategy, Noop)
    assert table.alias == "bar"
    assert table.isolate_func is not None
    assert table.isolate_func(table) == "table_barbar"
    assert len(table.create_options) == 1
    assert isinstance(table.partition_type, IngestionTime)
    assert table.schema == schema
def test_change_isolate():
    conf = BQTestKitConfig({
        DEFAULT_LOCATION: "EU"
    }).with_test_context("context")
    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.isolate()
    assert table.isolate_func(table) == f"{table.name}_context"
    assert table.fqdn() == (f"{table.dataset.project.name}."
                            f"{table.dataset.name}."
                            f"{table.name}_context")
def test_default_constructor():
    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)
    assert table.dataset.project.name == "test_project"
    assert table.dataset.name == "dataset_foo"
    assert table.name == "table_bar"
    assert isinstance(table.resource_strategy, CleanAfter)
    assert table.alias is None
    assert table.isolate_func(table) == "table_bar"
    assert table.create_options == {}
    assert table.schema == []
    assert isinstance(table.partition_type, NoPartition)