mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-08 15:28:26 +01:00
* tests: use remote fixtures * tests: use remote fixtures for data cloud tests * tests: treat remotes as tmp dirs
46 lines
880 B
Python
46 lines
880 B
Python
import os
|
|
import uuid
|
|
|
|
import pytest
|
|
|
|
from dvc.utils import env2bool
|
|
|
|
from .base import Base
|
|
|
|
TEST_OSS_REPO_BUCKET = "dvc-test"
|
|
|
|
|
|
class OSS(Base):
|
|
@staticmethod
|
|
def should_test():
|
|
do_test = env2bool("DVC_TEST_OSS", undefined=None)
|
|
if do_test is not None:
|
|
return do_test
|
|
|
|
return (
|
|
os.getenv("OSS_ENDPOINT")
|
|
and os.getenv("OSS_ACCESS_KEY_ID")
|
|
and os.getenv("OSS_ACCESS_KEY_SECRET")
|
|
)
|
|
|
|
@staticmethod
|
|
def get_storagepath():
|
|
return f"{TEST_OSS_REPO_BUCKET}/{uuid.uuid4()}"
|
|
|
|
@staticmethod
|
|
def get_url():
|
|
return f"oss://{OSS.get_storagepath()}"
|
|
|
|
|
|
@pytest.fixture
|
|
def oss():
|
|
if not OSS.should_test():
|
|
pytest.skip("no oss running")
|
|
yield OSS()
|
|
|
|
|
|
@pytest.fixture
|
|
def oss_remote(tmp_dir, dvc, oss):
|
|
tmp_dir.add_remote(config=oss.config)
|
|
yield oss
|