|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -from typing import Iterator |
| 15 | +from typing import Generator, Iterator |
16 | 16 |
|
17 | | -from google.cloud import bigquery |
| 17 | +from google.cloud import bigquery, storage |
18 | 18 | import pytest |
19 | 19 | import test_utils.prefixer |
20 | 20 |
|
@@ -42,11 +42,27 @@ def bigquery_client() -> bigquery.Client: |
42 | 42 | return bigquery_client |
43 | 43 |
|
44 | 44 |
|
| 45 | +@pytest.fixture(scope="session") |
| 46 | +def storage_client(project_id: str) -> storage.Client: |
| 47 | + return storage.Client(project=project_id) |
| 48 | + |
| 49 | + |
45 | 50 | @pytest.fixture(scope="session") |
46 | 51 | def project_id(bigquery_client: bigquery.Client) -> str: |
47 | 52 | return bigquery_client.project |
48 | 53 |
|
49 | 54 |
|
| 55 | +@pytest.fixture(scope="session") |
| 56 | +def gcs_bucket(storage_client: storage.Client) -> Generator[str, None, None]: |
| 57 | + bucket_name = "bigframes_blob_test_with_data_wipeout" |
| 58 | + |
| 59 | + yield bucket_name |
| 60 | + |
| 61 | + bucket = storage_client.get_bucket(bucket_name) |
| 62 | + for blob in bucket.list_blobs(): |
| 63 | + blob.delete() |
| 64 | + |
| 65 | + |
50 | 66 | @pytest.fixture(autouse=True) |
51 | 67 | def reset_session() -> None: |
52 | 68 | """An autouse fixture ensuring each sample runs in a fresh session. |
@@ -78,11 +94,6 @@ def dataset_id_eu(bigquery_client: bigquery.Client, project_id: str) -> Iterator |
78 | 94 | bigquery_client.delete_dataset(dataset, delete_contents=True, not_found_ok=True) |
79 | 95 |
|
80 | 96 |
|
81 | | -@pytest.fixture(scope="session") |
82 | | -def gcs_dst_bucket() -> str: |
83 | | - return "gs://bigframes_blob_test" |
84 | | - |
85 | | - |
86 | 97 | @pytest.fixture |
87 | 98 | def random_model_id( |
88 | 99 | bigquery_client: bigquery.Client, project_id: str, dataset_id: str |
|
0 commit comments