Skip to content

Commit 177c8da

Browse files
committed
Test-only improvements
1 parent 5f20e5c commit 177c8da

File tree

9 files changed

+46
-54
lines changed

9 files changed

+46
-54
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ dev = [
6060
"pytest-cov>=5.0",
6161
"sphinx>=7.3",
6262
"sphinx_rtd_theme>=2.0",
63+
"allure-pytest>=2.15",
6364
"types-setuptools",
6465
]
6566

tests/conftest.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class GlobalData:
2828
username: str = generate_username()
2929
cluster: bool = False
3030
enterprise: bool = False
31-
db_version: version = version.parse("0.0.0")
31+
skip: list[str] = None
32+
db_version: version.Version = version.parse("0.0.0")
3233

3334

3435
global_data = GlobalData()
@@ -54,7 +55,23 @@ def pytest_addoption(parser):
5455
"--cluster", action="store_true", help="Run tests in a cluster setup"
5556
)
5657
parser.addoption(
57-
"--enterprise", action="store_true", help="Run tests in an enterprise setup"
58+
"--enterprise",
59+
action="store_true",
60+
default=True,
61+
help="Run tests in an enterprise setup",
62+
)
63+
parser.addoption(
64+
"--skip",
65+
action="store",
66+
nargs="*",
67+
choices=[
68+
"backup", # backup tests
69+
"jwt-secret-keyfile", # server was not configured with a keyfile
70+
"foxx", # foxx is not supported
71+
"js-transactions", # javascript transactions are not supported
72+
],
73+
default=[],
74+
help="Skip specific tests",
5875
)
5976

6077

@@ -70,6 +87,7 @@ def pytest_configure(config):
7087
global_data.token = JwtToken.generate_token(global_data.secret)
7188
global_data.cluster = config.getoption("cluster")
7289
global_data.enterprise = config.getoption("enterprise")
90+
global_data.skip = config.getoption("skip")
7391
global_data.graph_name = generate_graph_name()
7492

7593
async def get_db_version():
@@ -111,6 +129,11 @@ def cluster():
111129
return global_data.cluster
112130

113131

132+
@pytest.fixture
133+
def skip_tests():
134+
return global_data.skip
135+
136+
114137
@pytest.fixture
115138
def enterprise():
116139
return global_data.enterprise

tests/static/cluster-3.11.conf

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/static/single-3.11.conf

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/test_aql.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,17 +279,15 @@ async def test_cache_plan_management(db, bad_db, doc_col, docs, db_version):
279279
entries = await cache.plan_entries()
280280
assert isinstance(entries, list)
281281
assert len(entries) > 0
282-
with pytest.raises(AQLCacheEntriesError) as err:
283-
_ = await bad_db.aql.cache.plan_entries()
284-
assert err.value.error_code == FORBIDDEN
282+
with pytest.raises(AQLCacheEntriesError):
283+
await bad_db.aql.cache.plan_entries()
285284

286285
# Clear the cache
287286
await cache.clear_plan()
288287
entries = await cache.plan_entries()
289288
assert len(entries) == 0
290-
with pytest.raises(AQLCacheClearError) as err:
289+
with pytest.raises(AQLCacheClearError):
291290
await bad_db.aql.cache.clear_plan()
292-
assert err.value.error_code == FORBIDDEN
293291

294292

295293
@pytest.mark.asyncio

tests/test_backup.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@
22
from packaging import version
33

44
from arangoasync.client import ArangoClient
5-
from arangoasync.exceptions import (
6-
BackupCreateError,
7-
BackupDeleteError,
8-
BackupDownloadError,
9-
BackupGetError,
10-
BackupRestoreError,
11-
BackupUploadError,
12-
)
5+
from arangoasync.exceptions import BackupDeleteError, BackupRestoreError
136

147

158
@pytest.mark.asyncio
16-
async def test_backup(url, sys_db_name, bad_db, token, enterprise, cluster, db_version):
9+
async def test_backup(
10+
url, sys_db_name, bad_db, token, enterprise, cluster, db_version, skip_tests
11+
):
1712
if not enterprise:
1813
pytest.skip("Backup API is only available in ArangoDB Enterprise Edition")
1914
if not cluster:
@@ -22,19 +17,13 @@ async def test_backup(url, sys_db_name, bad_db, token, enterprise, cluster, db_v
2217
pytest.skip(
2318
"For simplicity, the backup API is only tested in the latest versions"
2419
)
20+
if "backup" in skip_tests:
21+
pytest.skip("Skipping backup tests")
2522

26-
with pytest.raises(BackupCreateError):
27-
await bad_db.backup.create()
28-
with pytest.raises(BackupGetError):
29-
await bad_db.backup.get()
3023
with pytest.raises(BackupRestoreError):
3124
await bad_db.backup.restore("foobar")
3225
with pytest.raises(BackupDeleteError):
3326
await bad_db.backup.delete("foobar")
34-
with pytest.raises(BackupUploadError):
35-
await bad_db.backup.upload()
36-
with pytest.raises(BackupDownloadError):
37-
await bad_db.backup.download()
3827

3928
async with ArangoClient(hosts=url) as client:
4029
db = await client.db(

tests/test_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ async def test_client_jwt_auth(url, sys_db_name, basic_auth_root):
121121

122122
@pytest.mark.asyncio
123123
async def test_client_jwt_superuser_auth(
124-
url, sys_db_name, basic_auth_root, token, enterprise
124+
url, sys_db_name, basic_auth_root, token, enterprise, skip_tests
125125
):
126126
# successful authentication
127127
async with ArangoClient(hosts=url) as client:
@@ -130,7 +130,8 @@ async def test_client_jwt_superuser_auth(
130130
)
131131
if enterprise:
132132
await db.jwt_secrets()
133-
await db.reload_jwt_secrets()
133+
if "jwt-secret-keyfile" not in skip_tests:
134+
await db.reload_jwt_secrets()
134135

135136
# Get TLS data
136137
tls = await db.tls()

tests/test_foxx.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@
3535

3636

3737
@pytest.mark.asyncio
38-
async def test_foxx(db, bad_db):
38+
async def test_foxx(db, bad_db, skip_tests):
39+
if "foxx" in skip_tests:
40+
pytest.skip("Skipping Foxx tests")
41+
3942
# Test errors
4043
with pytest.raises(FoxxServiceGetError):
4144
await bad_db.foxx.service(service_name)

tests/test_transaction.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414

1515

1616
@pytest.mark.asyncio
17-
async def test_transaction_execute_raw(db, doc_col, docs):
17+
async def test_transaction_execute_raw(db, doc_col, docs, skip_tests):
18+
if "js-transactions" in skip_tests:
19+
pytest.skip("Skipping JS transaction tests")
20+
1821
# Test a valid JS transaction
1922
doc = docs[0]
2023
key = doc["_key"]

0 commit comments

Comments
 (0)