Skip to content

Commit 48991ab

Browse files
authored
Merge pull request #6904 fixing legacy pytest-fixture
Fixes #6881. See individual commits for detailed changes.
2 parents ec9d53e + 229c35a commit 48991ab

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

.github/workflows/ci-code.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,55 @@ jobs:
133133
verdi devel check-load-time
134134
verdi devel check-undesired-imports
135135
.github/workflows/verdi.sh
136+
137+
138+
test-pytest-fixtures:
139+
# Who watches the watchmen?
140+
# Here we test the pytest fixtures in isolation from the rest of aiida-core test suite,
141+
# since they can be used outside of aiida core context, e.g. in plugins.
142+
# Unlike in other workflows in this file, we purposefully don't setup a test profile.
143+
144+
runs-on: ubuntu-24.04
145+
timeout-minutes: 10
146+
147+
services:
148+
postgres:
149+
image: postgres:10
150+
env:
151+
POSTGRES_DB: test_aiida
152+
POSTGRES_PASSWORD: ''
153+
POSTGRES_HOST_AUTH_METHOD: trust
154+
options: >-
155+
--health-cmd pg_isready
156+
--health-interval 10s
157+
--health-timeout 5s
158+
--health-retries 5
159+
ports:
160+
- 5432:5432
161+
rabbitmq:
162+
image: rabbitmq:3.8.14-management
163+
ports:
164+
- 5672:5672
165+
- 15672:15672
166+
167+
steps:
168+
- uses: actions/checkout@v4
169+
170+
- name: Install aiida-core
171+
uses: ./.github/actions/install-aiida-core
172+
with:
173+
python-version: '3.9'
174+
from-lock: 'true'
175+
extras: tests
176+
177+
- name: Test legacy pytest fixtures
178+
run: pytest --cov aiida --noconftest src/aiida/manage/tests/test_pytest_fixtures.py
179+
180+
- name: Upload coverage report
181+
if: github.repository == 'aiidateam/aiida-core'
182+
uses: codecov/codecov-action@v5
183+
with:
184+
token: ${{ secrets.CODECOV_TOKEN }}
185+
name: test-pytest-fixtures
186+
files: ./coverage.xml
187+
fail_ci_if_error: false # don't fail job, if coverage upload fails

src/aiida/manage/tests/pytest_fixtures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def aiida_instance(
179179
current_profile = configuration.get_profile()
180180
current_path_variable = os.environ.get(settings.DEFAULT_AIIDA_PATH_VARIABLE, None)
181181

182-
dirpath_config = tmp_path_factory.mktemp('config')
182+
dirpath_config = tmp_path_factory.mktemp('config') / settings.DEFAULT_CONFIG_DIR_NAME
183183
os.environ[settings.DEFAULT_AIIDA_PATH_VARIABLE] = str(dirpath_config)
184184
AiiDAConfigDir.set(dirpath_config)
185185
configuration.CONFIG = configuration.load_config(create=True)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Tests for the :mod:`aiida.manage.tests.pytest_fixtures` module."""
2+
3+
pytest_plugins = ['aiida.manage.tests.pytest_fixtures']
4+
5+
6+
def test_deamon_client(daemon_client):
7+
if daemon_client.is_daemon_running:
8+
daemon_client.stop_daemon(wait=True)
9+
daemon_client.start_daemon()
10+
daemon_client.stop_daemon(wait=True)
11+
12+
13+
def test_started_daemon_client(started_daemon_client):
14+
assert started_daemon_client.is_daemon_running
15+
16+
17+
def test_stopped_daemon_client(stopped_daemon_client):
18+
assert not stopped_daemon_client.is_daemon_running

0 commit comments

Comments
 (0)