Skip to content

Commit

Permalink
Test automarked requires_psql|nightly tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas authored and GeigerJ2 committed Nov 25, 2024
1 parent 0232a9d commit 570e860
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
13 changes: 4 additions & 9 deletions tests/storage/psql_dos/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@
from aiida.common.exceptions import MissingConfigurationError
from aiida.manage.configuration import get_config

STORAGE_BACKEND_ENTRY_POINT = None
try:
if test_profile := os.environ.get('AIIDA_TEST_PROFILE'):
STORAGE_BACKEND_ENTRY_POINT = get_config().get_profile(test_profile).storage_backend
# TODO: The else branch is wrong
else:
STORAGE_BACKEND_ENTRY_POINT = 'core.psql_dos'
except MissingConfigurationError:
# TODO: This is actually not true anymore!
# Case when ``pytest`` is invoked without existing config, in which case it will rely on the automatic test profile
# creation which currently always uses ``core.psql_dos`` for the storage backend
STORAGE_BACKEND_ENTRY_POINT = 'core.psql_dos'
except MissingConfigurationError as e:
raise ValueError(f"Could not parse configuration of AiiDA test profile '{test_profile}'") from e

if STORAGE_BACKEND_ENTRY_POINT != 'core.psql_dos':
if STORAGE_BACKEND_ENTRY_POINT is not None and STORAGE_BACKEND_ENTRY_POINT != 'core.psql_dos':
collect_ignore_glob = ['*']
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
from aiida.storage.psql_dos.migrator import PsqlDosMigrator


def test_all_tests_marked_as_nightly(request):
"""Test that all tests in this folder are tagged with 'nightly' marker"""
own_markers = [marker.name for marker in request.node.own_markers]

assert len(own_markers) == 2
assert 'nightly' in own_markers
assert 'requires_psql' in own_markers


def test_migrate(perform_migrations: PsqlDosMigrator):
"""Test that the migrator can migrate from the base of the django branch, to the main head."""
perform_migrations.migrate_up('django@django_0001') # the base of the django branch
Expand Down
8 changes: 8 additions & 0 deletions tests/storage/psql_dos/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
from aiida.orm import User


def test_all_tests_marked_with_requires_psql(request):
"""Test that all tests in this folder are marked 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.usefixtures('aiida_profile_clean')
def test_default_user():
assert isinstance(get_manager().get_profile_storage().default_user, User)
Expand Down

0 comments on commit 570e860

Please sign in to comment.