Skip to content

Commit 219d71a

Browse files
authored
Test-only improvements (#73)
* Test-only improvements * enterprise option is obsolete * Updating circleci config * Fix smartgraph
1 parent 5f20e5c commit 219d71a

File tree

14 files changed

+48
-70
lines changed

14 files changed

+48
-70
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ jobs:
8686
args+=("--cluster" "--port=8539" "--port=8549")
8787
fi
8888
89-
if [ << parameters.arangodb_license >> = "enterprise" ]; then
90-
args+=("--enterprise")
89+
if [ << parameters.arangodb_license >> != "enterprise" ]; then
90+
args+=("--skip enterprise")
9191
fi
9292
9393
echo "Running pytest with args: ${args[@]}"

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: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class GlobalData:
2727
graph_name: str = "test_graph"
2828
username: str = generate_username()
2929
cluster: bool = False
30-
enterprise: bool = False
31-
db_version: version = version.parse("0.0.0")
30+
skip: list[str] = None
31+
db_version: version.Version = version.parse("0.0.0")
3232

3333

3434
global_data = GlobalData()
@@ -54,7 +54,18 @@ def pytest_addoption(parser):
5454
"--cluster", action="store_true", help="Run tests in a cluster setup"
5555
)
5656
parser.addoption(
57-
"--enterprise", action="store_true", help="Run tests in an enterprise setup"
57+
"--skip",
58+
action="store",
59+
nargs="*",
60+
choices=[
61+
"backup", # backup tests
62+
"jwt-secret-keyfile", # server was not configured with a keyfile
63+
"foxx", # foxx is not supported
64+
"js-transactions", # javascript transactions are not supported
65+
"enterprise", # skip what used to be "enterprise-only" before 3.12
66+
],
67+
default=[],
68+
help="Skip specific tests",
5869
)
5970

6071

@@ -69,7 +80,7 @@ def pytest_configure(config):
6980
global_data.secret = config.getoption("secret")
7081
global_data.token = JwtToken.generate_token(global_data.secret)
7182
global_data.cluster = config.getoption("cluster")
72-
global_data.enterprise = config.getoption("enterprise")
83+
global_data.skip = config.getoption("skip")
7384
global_data.graph_name = generate_graph_name()
7485

7586
async def get_db_version():
@@ -112,8 +123,8 @@ def cluster():
112123

113124

114125
@pytest.fixture
115-
def enterprise():
116-
return global_data.enterprise
126+
def skip_tests():
127+
return global_data.skip
117128

118129

119130
@pytest.fixture

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_analyzer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
@pytest.mark.asyncio
14-
async def test_analyzer_management(db, bad_db, enterprise, db_version):
14+
async def test_analyzer_management(db, bad_db, skip_tests, db_version):
1515
analyzer_name = generate_analyzer_name()
1616
full_analyzer_name = db.name + "::" + analyzer_name
1717
bad_analyzer_name = generate_analyzer_name()
@@ -68,7 +68,7 @@ async def test_analyzer_management(db, bad_db, enterprise, db_version):
6868
assert await db.delete_analyzer(analyzer_name, ignore_missing=True) is False
6969

7070
# Test create geo_s2 analyzer
71-
if enterprise:
71+
if "enterprise" not in skip_tests:
7272
analyzer_name = generate_analyzer_name()
7373
result = await db.create_analyzer(analyzer_name, "geo_s2", properties={})
7474
assert result["type"] == "geo_s2"

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: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,26 @@
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):
17-
if not enterprise:
9+
async def test_backup(url, sys_db_name, bad_db, token, cluster, db_version, skip_tests):
10+
if "enterprise" in skip_tests:
1811
pytest.skip("Backup API is only available in ArangoDB Enterprise Edition")
1912
if not cluster:
2013
pytest.skip("For simplicity, the backup API is only tested in cluster setups")
2114
if db_version < version.parse("3.12.0"):
2215
pytest.skip(
2316
"For simplicity, the backup API is only tested in the latest versions"
2417
)
18+
if "backup" in skip_tests:
19+
pytest.skip("Skipping backup tests")
2520

26-
with pytest.raises(BackupCreateError):
27-
await bad_db.backup.create()
28-
with pytest.raises(BackupGetError):
29-
await bad_db.backup.get()
3021
with pytest.raises(BackupRestoreError):
3122
await bad_db.backup.restore("foobar")
3223
with pytest.raises(BackupDeleteError):
3324
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()
3825

3926
async with ArangoClient(hosts=url) as client:
4027
db = await client.db(

tests/test_client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,17 @@ 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, skip_tests
125125
):
126126
# successful authentication
127127
async with ArangoClient(hosts=url) as client:
128128
db = await client.db(
129129
sys_db_name, auth_method="superuser", token=token, verify=True
130130
)
131-
if enterprise:
131+
if "enterprise" not in skip_tests:
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_cluster.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515

1616
@pytest.mark.asyncio
1717
async def test_cluster(
18-
url, sys_db_name, bad_db, token, enterprise, cluster, db_version
18+
url, sys_db_name, bad_db, token, skip_tests, cluster, db_version
1919
):
2020
if not cluster:
2121
pytest.skip("Cluster API is only tested in cluster setups")
22-
if not enterprise or db_version < version.parse("3.12.0"):
22+
if "enterprise" in skip_tests or db_version < version.parse("3.12.0"):
2323
pytest.skip(
2424
"For simplicity, the cluster API is only tested in the latest versions"
2525
)

0 commit comments

Comments
 (0)