Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ jobs:
args+=("--cluster" "--port=8539" "--port=8549")
fi
if [ << parameters.arangodb_license >> = "enterprise" ]; then
args+=("--enterprise")
if [ << parameters.arangodb_license >> != "enterprise" ]; then
args+=("--skip enterprise")
fi
echo "Running pytest with args: ${args[@]}"
Expand Down
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
23 changes: 17 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class GlobalData:
graph_name: str = "test_graph"
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 +54,18 @@ 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"
"--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
"enterprise", # skip what used to be "enterprise-only" before 3.12
],
default=[],
help="Skip specific tests",
)


Expand All @@ -69,7 +80,7 @@ def pytest_configure(config):
global_data.secret = config.getoption("secret")
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 @@ -112,8 +123,8 @@ def cluster():


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


@pytest.fixture
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.

4 changes: 2 additions & 2 deletions tests/test_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


@pytest.mark.asyncio
async def test_analyzer_management(db, bad_db, enterprise, db_version):
async def test_analyzer_management(db, bad_db, skip_tests, db_version):
analyzer_name = generate_analyzer_name()
full_analyzer_name = db.name + "::" + analyzer_name
bad_analyzer_name = generate_analyzer_name()
Expand Down Expand Up @@ -68,7 +68,7 @@ async def test_analyzer_management(db, bad_db, enterprise, db_version):
assert await db.delete_analyzer(analyzer_name, ignore_missing=True) is False

# Test create geo_s2 analyzer
if enterprise:
if "enterprise" not in skip_tests:
analyzer_name = generate_analyzer_name()
result = await db.create_analyzer(analyzer_name, "geo_s2", properties={})
assert result["type"] == "geo_s2"
Expand Down
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: 5 additions & 18 deletions tests/test_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,26 @@
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):
if not enterprise:
async def test_backup(url, sys_db_name, bad_db, token, cluster, db_version, skip_tests):
if "enterprise" in skip_tests:
pytest.skip("Backup API is only available in ArangoDB Enterprise Edition")
if not cluster:
pytest.skip("For simplicity, the backup API is only tested in cluster setups")
if db_version < version.parse("3.12.0"):
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
7 changes: 4 additions & 3 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,17 @@ 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, skip_tests
):
# successful authentication
async with ArangoClient(hosts=url) as client:
db = await client.db(
sys_db_name, auth_method="superuser", token=token, verify=True
)
if enterprise:
if "enterprise" not in skip_tests:
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
4 changes: 2 additions & 2 deletions tests/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

@pytest.mark.asyncio
async def test_cluster(
url, sys_db_name, bad_db, token, enterprise, cluster, db_version
url, sys_db_name, bad_db, token, skip_tests, cluster, db_version
):
if not cluster:
pytest.skip("Cluster API is only tested in cluster setups")
if not enterprise or db_version < version.parse("3.12.0"):
if "enterprise" in skip_tests or db_version < version.parse("3.12.0"):
pytest.skip(
"For simplicity, the cluster API is only tested in the latest versions"
)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

@pytest.mark.asyncio
async def test_database_misc_methods(
sys_db, db, bad_db, cluster, db_version, url, sys_db_name, token, enterprise
sys_db, db, bad_db, cluster, db_version, url, sys_db_name, token, skip_tests
):
# Status
status = await sys_db.status()
Expand Down Expand Up @@ -181,7 +181,7 @@ async def test_database_misc_methods(
response = await sys_db.request(request)
assert json.loads(response.raw_body) == 1

if enterprise and db_version >= version.parse("3.12.0"):
if "enterprise" not in skip_tests and db_version >= version.parse("3.12.0"):
# API calls
with pytest.raises(ServerApiCallsError):
await bad_db.api_calls()
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
4 changes: 2 additions & 2 deletions tests/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ async def test_graph_basic(db, bad_db):


@pytest.mark.asyncio
async def test_graph_properties(db, bad_graph, cluster, enterprise):
async def test_graph_properties(db, bad_graph, cluster, skip_tests):
# Create a graph
name = generate_graph_name()
is_smart = cluster and enterprise
is_smart = cluster and "enterprise" in skip_tests
options = GraphOptions(number_of_shards=3)
graph = await db.create_graph(name, is_smart=is_smart, options=options)

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