Skip to content

Commit

Permalink
Add tests for presto markers
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas committed Nov 21, 2024
1 parent 95435ef commit df23e15
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def pytest_collection_modifyitems(items, config):
if config.option.db_backend is DbBackend.SQLITE:
if config.option.markexpr != '':
# Don't overwrite markers that the user already provided via '-m ' cmdline argument
config.option.markexpr += ' and not requires_psql'
config.option.markexpr += ' and (not requires_psql)'
else:
config.option.markexpr = 'not requires_psql'

Expand Down Expand Up @@ -119,7 +119,7 @@ def aiida_profile(pytestconfig, aiida_config, aiida_profile_factory, config_psql
marker_opts = pytestconfig.getoption('-m')
db_backend = pytestconfig.getoption('--db-backend')

# By default we use RabbitMQ broker and psql_dos storage
# We use RabbitMQ broker by default unless 'presto' marker is specified
broker = 'core.rabbitmq'
if 'not requires_rmq' in marker_opts or 'presto' in marker_opts:
broker = None
Expand Down
47 changes: 47 additions & 0 deletions tests/test_markers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""Tests markers that have custom logic applied to them"""

import pytest


def test_presto_auto_mark(request):
"""Test that the presto marker is added automatically"""
own_markers = [marker.name for marker in request.node.own_markers]
assert len(own_markers) == 1
assert own_markers[0] == 'presto'


@pytest.mark.sphinx
def test_presto_mark_and_another_mark(request):
"""Test that presto marker is added even if there is an existing marker (except requires_rmq|psql)"""
own_markers = [marker.name for marker in request.node.own_markers]

assert len(own_markers) == 2
assert 'presto' in own_markers
assert 'sphinx' in own_markers


@pytest.mark.requires_rmq
def test_no_presto_mark_if_rmq(request):
"""Test that presto marker is NOT added if the test is mark with "requires_rmq"""
own_markers = [marker.name for marker in request.node.own_markers]

assert len(own_markers) == 1
assert own_markers[0] == 'requires_rmq'


@pytest.mark.requires_psql
def test_no_presto_mark_if_psql(request):
"""Test that presto marker is NOT added if the test is mark with "requires_psql"""
own_markers = [marker.name for marker in request.node.own_markers]

assert len(own_markers) == 1
assert own_markers[0] == 'requires_psql'


@pytest.mark.nightly
def test_no_presto_mark_if_nightly(request):
"""Test that presto marker is NOT added if the test is mark with "requires_psql"""
own_markers = [marker.name for marker in request.node.own_markers]

assert len(own_markers) == 1
assert own_markers[0] == 'nightly'

0 comments on commit df23e15

Please sign in to comment.