Skip to content

Commit e833767

Browse files
authored
Adding test parameters for foxx service path and backup path (#76)
1 parent eb4922a commit e833767

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed

tests/conftest.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class GlobalData:
2828
username: str = generate_username()
2929
cluster: bool = False
3030
skip: list[str] = None
31+
foxx_path: str = None
32+
backup_path: str = None
3133
db_version: version.Version = version.parse("0.0.0")
3234

3335

@@ -53,6 +55,18 @@ def pytest_addoption(parser):
5355
parser.addoption(
5456
"--cluster", action="store_true", help="Run tests in a cluster setup"
5557
)
58+
parser.addoption(
59+
"--foxx-path",
60+
action="store",
61+
default="/tests/static/service.zip",
62+
help="Foxx tests service path",
63+
)
64+
parser.addoption(
65+
"--backup-path",
66+
action="store",
67+
default="local://tmp",
68+
help="Backup tests repository path",
69+
)
5670
parser.addoption(
5771
"--skip",
5872
action="store",
@@ -82,6 +96,8 @@ def pytest_configure(config):
8296
global_data.token = JwtToken.generate_token(global_data.secret)
8397
global_data.cluster = config.getoption("cluster")
8498
global_data.skip = config.getoption("skip")
99+
global_data.backup_path = config.getoption("backup_path")
100+
global_data.foxx_path = config.getoption("foxx_path")
85101
global_data.graph_name = generate_graph_name()
86102

87103
async def get_db_version():
@@ -123,6 +139,16 @@ def cluster():
123139
return global_data.cluster
124140

125141

142+
@pytest.fixture
143+
def backup_path():
144+
return global_data.backup_path
145+
146+
147+
@pytest.fixture
148+
def foxx_path():
149+
return global_data.foxx_path
150+
151+
126152
@pytest.fixture
127153
def skip_tests():
128154
return global_data.skip

tests/test_backup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77

88
@pytest.mark.asyncio
9-
async def test_backup(url, sys_db_name, bad_db, token, cluster, db_version, skip_tests):
9+
async def test_backup(
10+
url, sys_db_name, bad_db, token, cluster, db_version, skip_tests, backup_path
11+
):
1012
if "enterprise" in skip_tests:
1113
pytest.skip("Backup API is only available in ArangoDB Enterprise Edition")
1214
if not cluster:
@@ -35,10 +37,8 @@ async def test_backup(url, sys_db_name, bad_db, token, cluster, db_version, skip
3537
result = await backup.restore(backup_id)
3638
assert "previous" in result
3739
config = {"local": {"type": "local"}}
38-
result = await backup.upload(backup_id, repository="local://tmp", config=config)
40+
result = await backup.upload(backup_id, repository=backup_path, config=config)
3941
assert "uploadId" in result
40-
result = await backup.download(
41-
backup_id, repository="local://tmp", config=config
42-
)
42+
result = await backup.download(backup_id, repository=backup_path, config=config)
4343
assert "downloadId" in result
4444
await backup.delete(backup_id)

tests/test_foxx.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@
3030
)
3131
from tests.helpers import generate_service_mount
3232

33-
service_file = "/tests/static/service.zip"
3433
service_name = "test"
3534

3635

3736
@pytest.mark.asyncio
38-
async def test_foxx(db, bad_db, skip_tests):
37+
async def test_foxx(db, bad_db, skip_tests, foxx_path):
3938
if "foxx" in skip_tests:
4039
pytest.skip("Skipping Foxx tests")
4140

@@ -90,7 +89,7 @@ async def test_foxx(db, bad_db, skip_tests):
9089
# Service as a path
9190
mount1 = generate_service_mount()
9291
service1 = {
93-
"source": service_file,
92+
"source": foxx_path,
9493
"configuration": {"LOG_LEVEL": "info"},
9594
"dependencies": {},
9695
}
@@ -102,7 +101,7 @@ async def test_foxx(db, bad_db, skip_tests):
102101
service2 = aiohttp.FormData()
103102
service2.add_field(
104103
"source",
105-
open(f".{service_file}", "rb"),
104+
open(f".{foxx_path}", "rb"),
106105
filename="service.zip",
107106
content_type="application/zip",
108107
)
@@ -115,7 +114,7 @@ async def test_foxx(db, bad_db, skip_tests):
115114

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

128127
# Replace service
129128
service4 = {
130-
"source": service_file,
129+
"source": foxx_path,
131130
"configuration": {"LOG_LEVEL": "info"},
132131
"dependencies": {},
133132
}
134133
service_info = await db.foxx.replace_service(mount=mount2, service=service4)
135134
assert service_info["mount"] == mount2
136135

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

144143
# Update service
145144
service6 = {
146-
"source": service_file,
145+
"source": foxx_path,
147146
"configuration": {"LOG_LEVEL": "debug"},
148147
"dependencies": {},
149148
}

0 commit comments

Comments
 (0)