|
| 1 | +# Copyright (c) TileDB, Inc. |
| 2 | +# Licensed under the MIT License. |
| 3 | + |
| 4 | +from __future__ import annotations |
| 5 | + |
| 6 | +import os |
| 7 | +from collections.abc import Generator |
| 8 | +from uuid import uuid4 |
| 9 | + |
| 10 | +import tiledbvcf |
| 11 | +import tiledb |
| 12 | +import pytest |
| 13 | + |
| 14 | + |
| 15 | +# Base CARRARA URI used for all tests. |
| 16 | +# - The teamspace must be owned by the test user. |
| 17 | +# - The workspace must match the workspace defined in the profile. |
| 18 | +PROFILE_NAME = os.getenv("CARRARA_TEST_PROFILE") or "qa" |
| 19 | +WORKSPACE_NAME = os.getenv("CARRARA_TEST_WORKSPACE") or "TileDB-Inc." |
| 20 | +TEAMSPACE_NAME = os.getenv("CARRARA_TEST_TEAMSPACE") or "uat-tests" |
| 21 | +TEST_FOLDER = os.getenv("CARRARA_TEST_FOLDER") or "remote_test" |
| 22 | +BASE_URI = f"tiledb://{WORKSPACE_NAME}/{TEAMSPACE_NAME}/{TEST_FOLDER}" |
| 23 | + |
| 24 | + |
| 25 | +@pytest.fixture(scope="session") |
| 26 | +def carrara_login() -> None: |
| 27 | + import tiledb.client |
| 28 | + |
| 29 | + tiledb.client.login(profile_name=PROFILE_NAME) |
| 30 | + assert tiledb.client.workspaces.get_workspace(tiledb.client.client.get_workspace_id()).name == WORKSPACE_NAME |
| 31 | + |
| 32 | + |
| 33 | +@pytest.fixture |
| 34 | +def carrara_array_path() -> Generator[str, None, None]: |
| 35 | + """Fixture returns an Array path that will be recursively deleted after test finishes.""" |
| 36 | + import tiledb.client |
| 37 | + |
| 38 | + path = f"{BASE_URI}/{uuid4()}" |
| 39 | + yield path |
| 40 | + |
| 41 | + tiledb.client.assets.delete_asset(path, delete_storage=True) |
| 42 | + |
| 43 | + |
| 44 | +@pytest.fixture |
| 45 | +def carrara_group_path() -> Generator[str, None, None]: |
| 46 | + """Fixture returns a Group path that will be recursively deleted after test finishes.""" |
| 47 | + path = f"{BASE_URI}/{uuid4()}" |
| 48 | + yield path |
| 49 | + |
| 50 | + try: |
| 51 | + with tiledb.Group(path, mode="m") as G: |
| 52 | + G.delete(recursive=True) |
| 53 | + except tiledb.TileDBError: |
| 54 | + pass |
| 55 | + |
| 56 | + |
0 commit comments