Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class GlobalData:
username: str = generate_username()
cluster: bool = False
skip: list[str] = None
foxx_path: str = None
backup_path: str = None
db_version: version.Version = version.parse("0.0.0")


Expand All @@ -53,6 +55,18 @@ def pytest_addoption(parser):
parser.addoption(
"--cluster", action="store_true", help="Run tests in a cluster setup"
)
parser.addoption(
"--foxx-path",
action="store",
default="/tests/static/service.zip",
help="Foxx tests service path",
)
parser.addoption(
"--backup-path",
action="store",
default="local://tmp",
help="Backup tests repository path",
)
parser.addoption(
"--skip",
action="store",
Expand Down Expand Up @@ -82,6 +96,8 @@ def pytest_configure(config):
global_data.token = JwtToken.generate_token(global_data.secret)
global_data.cluster = config.getoption("cluster")
global_data.skip = config.getoption("skip")
global_data.backup_path = config.getoption("backup_path")
global_data.foxx_path = config.getoption("foxx_path")
global_data.graph_name = generate_graph_name()

async def get_db_version():
Expand Down Expand Up @@ -123,6 +139,16 @@ def cluster():
return global_data.cluster


@pytest.fixture
def backup_path():
return global_data.backup_path


@pytest.fixture
def foxx_path():
return global_data.foxx_path


@pytest.fixture
def skip_tests():
return global_data.skip
Expand Down
10 changes: 5 additions & 5 deletions tests/test_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@


@pytest.mark.asyncio
async def test_backup(url, sys_db_name, bad_db, token, cluster, db_version, skip_tests):
async def test_backup(
url, sys_db_name, bad_db, token, cluster, db_version, skip_tests, backup_path
):
if "enterprise" in skip_tests:
pytest.skip("Backup API is only available in ArangoDB Enterprise Edition")
if not cluster:
Expand Down Expand Up @@ -35,10 +37,8 @@ async def test_backup(url, sys_db_name, bad_db, token, cluster, db_version, skip
result = await backup.restore(backup_id)
assert "previous" in result
config = {"local": {"type": "local"}}
result = await backup.upload(backup_id, repository="local://tmp", config=config)
result = await backup.upload(backup_id, repository=backup_path, config=config)
assert "uploadId" in result
result = await backup.download(
backup_id, repository="local://tmp", config=config
)
result = await backup.download(backup_id, repository=backup_path, config=config)
assert "downloadId" in result
await backup.delete(backup_id)
15 changes: 7 additions & 8 deletions tests/test_foxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@
)
from tests.helpers import generate_service_mount

service_file = "/tests/static/service.zip"
service_name = "test"


@pytest.mark.asyncio
async def test_foxx(db, bad_db, skip_tests):
async def test_foxx(db, bad_db, skip_tests, foxx_path):
if "foxx" in skip_tests:
pytest.skip("Skipping Foxx tests")

Expand Down Expand Up @@ -90,7 +89,7 @@ async def test_foxx(db, bad_db, skip_tests):
# Service as a path
mount1 = generate_service_mount()
service1 = {
"source": service_file,
"source": foxx_path,
"configuration": {"LOG_LEVEL": "info"},
"dependencies": {},
}
Expand All @@ -102,7 +101,7 @@ async def test_foxx(db, bad_db, skip_tests):
service2 = aiohttp.FormData()
service2.add_field(
"source",
open(f".{service_file}", "rb"),
open(f".{foxx_path}", "rb"),
filename="service.zip",
content_type="application/zip",
)
Expand All @@ -115,7 +114,7 @@ async def test_foxx(db, bad_db, skip_tests):

# Service as raw data
mount3 = generate_service_mount()
async with aiofiles.open(f".{service_file}", mode="rb") as f:
async with aiofiles.open(f".{foxx_path}", mode="rb") as f:
service3 = await f.read()
service_info = await db.foxx.create_service(
mount=mount3, service=service3, headers={"content-type": "application/zip"}
Expand All @@ -127,14 +126,14 @@ async def test_foxx(db, bad_db, skip_tests):

# Replace service
service4 = {
"source": service_file,
"source": foxx_path,
"configuration": {"LOG_LEVEL": "info"},
"dependencies": {},
}
service_info = await db.foxx.replace_service(mount=mount2, service=service4)
assert service_info["mount"] == mount2

async with aiofiles.open(f".{service_file}", mode="rb") as f:
async with aiofiles.open(f".{foxx_path}", mode="rb") as f:
service5 = await f.read()
service_info = await db.foxx.replace_service(
mount=mount1, service=service5, headers={"content-type": "application/zip"}
Expand All @@ -143,7 +142,7 @@ async def test_foxx(db, bad_db, skip_tests):

# Update service
service6 = {
"source": service_file,
"source": foxx_path,
"configuration": {"LOG_LEVEL": "debug"},
"dependencies": {},
}
Expand Down
Loading