Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ dev = [
"pytest-cov>=5.0",
"sphinx>=7.3",
"sphinx_rtd_theme>=2.0",
"allure-pytest>=2.15",
"types-setuptools",
]

Expand Down
27 changes: 25 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class GlobalData:
username: str = generate_username()
cluster: bool = False
enterprise: bool = False
db_version: version = version.parse("0.0.0")
skip: list[str] = None
db_version: version.Version = version.parse("0.0.0")


global_data = GlobalData()
Expand All @@ -54,7 +55,23 @@ def pytest_addoption(parser):
"--cluster", action="store_true", help="Run tests in a cluster setup"
)
parser.addoption(
"--enterprise", action="store_true", help="Run tests in an enterprise setup"
"--enterprise",
action="store_true",
default=True,
help="Run tests in an enterprise setup",
)
parser.addoption(
"--skip",
action="store",
nargs="*",
choices=[
"backup", # backup tests
"jwt-secret-keyfile", # server was not configured with a keyfile
"foxx", # foxx is not supported
"js-transactions", # javascript transactions are not supported
],
default=[],
help="Skip specific tests",
)


Expand All @@ -70,6 +87,7 @@ def pytest_configure(config):
global_data.token = JwtToken.generate_token(global_data.secret)
global_data.cluster = config.getoption("cluster")
global_data.enterprise = config.getoption("enterprise")
global_data.skip = config.getoption("skip")
global_data.graph_name = generate_graph_name()

async def get_db_version():
Expand Down Expand Up @@ -111,6 +129,11 @@ def cluster():
return global_data.cluster


@pytest.fixture
def skip_tests():
return global_data.skip


@pytest.fixture
def enterprise():
return global_data.enterprise
Expand Down
14 changes: 0 additions & 14 deletions tests/static/cluster-3.11.conf

This file was deleted.

12 changes: 0 additions & 12 deletions tests/static/single-3.11.conf

This file was deleted.

8 changes: 3 additions & 5 deletions tests/test_aql.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,15 @@ async def test_cache_plan_management(db, bad_db, doc_col, docs, db_version):
entries = await cache.plan_entries()
assert isinstance(entries, list)
assert len(entries) > 0
with pytest.raises(AQLCacheEntriesError) as err:
_ = await bad_db.aql.cache.plan_entries()
assert err.value.error_code == FORBIDDEN
with pytest.raises(AQLCacheEntriesError):
await bad_db.aql.cache.plan_entries()

# Clear the cache
await cache.clear_plan()
entries = await cache.plan_entries()
assert len(entries) == 0
with pytest.raises(AQLCacheClearError) as err:
with pytest.raises(AQLCacheClearError):
await bad_db.aql.cache.clear_plan()
assert err.value.error_code == FORBIDDEN


@pytest.mark.asyncio
Expand Down
23 changes: 6 additions & 17 deletions tests/test_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@
from packaging import version

from arangoasync.client import ArangoClient
from arangoasync.exceptions import (
BackupCreateError,
BackupDeleteError,
BackupDownloadError,
BackupGetError,
BackupRestoreError,
BackupUploadError,
)
from arangoasync.exceptions import BackupDeleteError, BackupRestoreError


@pytest.mark.asyncio
async def test_backup(url, sys_db_name, bad_db, token, enterprise, cluster, db_version):
async def test_backup(
url, sys_db_name, bad_db, token, enterprise, cluster, db_version, skip_tests
):
if not enterprise:
pytest.skip("Backup API is only available in ArangoDB Enterprise Edition")
if not cluster:
Expand All @@ -22,19 +17,13 @@ async def test_backup(url, sys_db_name, bad_db, token, enterprise, cluster, db_v
pytest.skip(
"For simplicity, the backup API is only tested in the latest versions"
)
if "backup" in skip_tests:
pytest.skip("Skipping backup tests")

with pytest.raises(BackupCreateError):
await bad_db.backup.create()
with pytest.raises(BackupGetError):
await bad_db.backup.get()
with pytest.raises(BackupRestoreError):
await bad_db.backup.restore("foobar")
with pytest.raises(BackupDeleteError):
await bad_db.backup.delete("foobar")
with pytest.raises(BackupUploadError):
await bad_db.backup.upload()
with pytest.raises(BackupDownloadError):
await bad_db.backup.download()

async with ArangoClient(hosts=url) as client:
db = await client.db(
Expand Down
5 changes: 3 additions & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async def test_client_jwt_auth(url, sys_db_name, basic_auth_root):

@pytest.mark.asyncio
async def test_client_jwt_superuser_auth(
url, sys_db_name, basic_auth_root, token, enterprise
url, sys_db_name, basic_auth_root, token, enterprise, skip_tests
):
# successful authentication
async with ArangoClient(hosts=url) as client:
Expand All @@ -130,7 +130,8 @@ async def test_client_jwt_superuser_auth(
)
if enterprise:
await db.jwt_secrets()
await db.reload_jwt_secrets()
if "jwt-secret-keyfile" not in skip_tests:
await db.reload_jwt_secrets()

# Get TLS data
tls = await db.tls()
Expand Down
5 changes: 4 additions & 1 deletion tests/test_foxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@


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

# Test errors
with pytest.raises(FoxxServiceGetError):
await bad_db.foxx.service(service_name)
Expand Down
5 changes: 4 additions & 1 deletion tests/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@


@pytest.mark.asyncio
async def test_transaction_execute_raw(db, doc_col, docs):
async def test_transaction_execute_raw(db, doc_col, docs, skip_tests):
if "js-transactions" in skip_tests:
pytest.skip("Skipping JS transaction tests")

# Test a valid JS transaction
doc = docs[0]
key = doc["_key"]
Expand Down
Loading