diff --git a/tests/conftest.py b/tests/conftest.py index f9b203f..5025142 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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") @@ -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", @@ -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(): @@ -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 diff --git a/tests/test_backup.py b/tests/test_backup.py index 3bb5492..7e6e37e 100644 --- a/tests/test_backup.py +++ b/tests/test_backup.py @@ -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: @@ -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) diff --git a/tests/test_foxx.py b/tests/test_foxx.py index c407215..e972dc2 100644 --- a/tests/test_foxx.py +++ b/tests/test_foxx.py @@ -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") @@ -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": {}, } @@ -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", ) @@ -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"} @@ -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"} @@ -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": {}, }