Skip to content

Commit 36b0fb4

Browse files
committed
Devops: Make use of the improved fixtures in aiida-core
Most notably, the `aiida_profile` and related fixtures now by default use a profile using the `core.sqlite_dos` storage plugin and define no broker. This means the PostgreSQL and RabbitMQ services are no longer required to run the tests.
1 parent 6d5afb6 commit 36b0fb4

19 files changed

+91
-112
lines changed

.github/workflows/cd.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@ jobs:
5454
matrix:
5555
python-version: ['3.9', '3.10', '3.11', '3.12']
5656

57-
services:
58-
postgres:
59-
image: postgres:12
60-
rabbitmq:
61-
image: rabbitmq:latest
62-
ports:
63-
- 5672:5672
64-
6557
steps:
6658
- uses: actions/checkout@v2
6759

.github/workflows/ci.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@ jobs:
3333
matrix:
3434
python-version: ['3.9', '3.10', '3.11', '3.12']
3535

36-
services:
37-
postgres:
38-
image: postgres:12
39-
rabbitmq:
40-
image: rabbitmq:latest
41-
ports:
42-
- 5672:5672
43-
4436
steps:
4537
- uses: actions/checkout@v2
4638

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ classifiers = [
1717
'Programming Language :: Python :: 3.12'
1818
]
1919
dependencies = [
20-
'aiida-core~=2.1',
20+
'aiida-core@git+https://github.com/sphuber/aiida-core@feature/improved-profile-fixtures',
2121
'click~=8.0',
2222
'pint~=0.23.0',
2323
'requests~=2.20'
@@ -46,7 +46,6 @@ requires-python = '>=3.9'
4646

4747
[project.optional-dependencies]
4848
dev = [
49-
'pgtest~=1.3',
5049
'pre-commit~=2.2',
5150
'pytest>=6.0'
5251
]

tests/cli/test_family.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from numpy.testing import assert_almost_equal
1313

1414

15-
@pytest.mark.usefixtures('clear_db')
15+
@pytest.mark.usefixtures('aiida_profile_clean')
1616
def test_family_cutoffs_set(run_cli_command, get_pseudo_family, generate_cutoffs_dict, tmp_path):
1717
"""Test the `aiida-pseudo family cutoffs set` command."""
1818
family = get_pseudo_family(cls=CutoffsPseudoPotentialFamily)
@@ -60,7 +60,7 @@ def test_family_cutoffs_set(run_cli_command, get_pseudo_family, generate_cutoffs
6060
assert family.get_cutoffs(stringency) == cutoffs_dict['high']
6161

6262

63-
@pytest.mark.usefixtures('clear_db')
63+
@pytest.mark.usefixtures('aiida_profile_clean')
6464
def test_family_cutoffs_set_unit(run_cli_command, get_pseudo_family, generate_cutoffs, tmp_path):
6565
"""Test the `aiida-pseudo family cutoffs set` command with the ``--unit`` flag."""
6666
family = get_pseudo_family(cls=CutoffsPseudoPotentialFamily)
@@ -97,7 +97,7 @@ def test_family_cutoffs_set_unit(run_cli_command, get_pseudo_family, generate_cu
9797
'family_cls,label',
9898
[(SsspFamily, 'SSSP/1.1/PBE/efficiency'), (PseudoDojoFamily, 'PseudoDojo/0.4/PBE/SR/standard/psp8')],
9999
)
100-
@pytest.mark.usefixtures('clear_db')
100+
@pytest.mark.usefixtures('aiida_profile_clean')
101101
def test_family_cutoffs_set_established(
102102
run_cli_command, get_pseudo_family, generate_cutoffs, tmp_path, family_cls, label
103103
):
@@ -117,7 +117,7 @@ def test_family_cutoffs_set_established(
117117
assert f"Invalid value for 'FAMILY': The value `{family}` is not allowed for this parameter." in result.output
118118

119119

120-
def test_family_show(clear_db, run_cli_command, get_pseudo_family):
120+
def test_family_show(aiida_profile_clean, run_cli_command, get_pseudo_family):
121121
"""Test the `aiida-pseudo show` command."""
122122
family = get_pseudo_family()
123123
result = run_cli_command(cmd_family_show, [family.label])
@@ -127,7 +127,9 @@ def test_family_show(clear_db, run_cli_command, get_pseudo_family):
127127
assert node.filename in result.output
128128

129129

130-
def test_family_show_recommended_cutoffs(clear_db, run_cli_command, get_pseudo_family, generate_cutoffs_dict):
130+
def test_family_show_recommended_cutoffs(
131+
aiida_profile_clean, run_cli_command, get_pseudo_family, generate_cutoffs_dict
132+
):
131133
"""Test the `aiida-pseudo show` command for a family with recommended cutoffs."""
132134
family = get_pseudo_family(cls=CutoffsPseudoPotentialFamily)
133135
stringencies = ('normal', 'high')
@@ -157,7 +159,7 @@ def test_family_show_recommended_cutoffs(clear_db, run_cli_command, get_pseudo_f
157159
assert_almost_equal(cutoffs[1], float(fields[4]))
158160

159161

160-
def test_family_show_argument_type(clear_db, run_cli_command, get_pseudo_family):
162+
def test_family_show_argument_type(aiida_profile_clean, run_cli_command, get_pseudo_family):
161163
"""Test that `aiida-pseudo show` only accepts instances of `PseudoPotentialFamily` or subclasses as argument."""
162164
pseudo_family = get_pseudo_family(label='pseudo-family', cls=PseudoPotentialFamily)
163165
normal_group = Group('normal-group').store()
@@ -166,7 +168,7 @@ def test_family_show_argument_type(clear_db, run_cli_command, get_pseudo_family)
166168
run_cli_command(cmd_family_show, [normal_group.label], raises=SystemExit)
167169

168170

169-
def test_family_show_raw(clear_db, run_cli_command, get_pseudo_family):
171+
def test_family_show_raw(aiida_profile_clean, run_cli_command, get_pseudo_family):
170172
"""Test the `-r/--raw` option."""
171173
family = get_pseudo_family()
172174

@@ -175,7 +177,7 @@ def test_family_show_raw(clear_db, run_cli_command, get_pseudo_family):
175177
assert len(result.output_lines) == len(family.nodes)
176178

177179

178-
def test_family_show_unit_default(clear_db, run_cli_command, get_pseudo_family):
180+
def test_family_show_unit_default(aiida_profile_clean, run_cli_command, get_pseudo_family):
179181
"""Test the `family show` command with default unit."""
180182
elements = ['Ar', 'Kr']
181183
cutoff_dict = {'normal': {'Ar': {'cutoff_wfc': 50, 'cutoff_rho': 200}, 'Kr': {'cutoff_wfc': 25, 'cutoff_rho': 100}}}
@@ -199,7 +201,7 @@ def test_family_show_unit_default(clear_db, run_cli_command, get_pseudo_family):
199201

200202

201203
@pytest.mark.parametrize('unit', ['Ry', 'eV', 'hartree', 'aJ'])
202-
def test_family_show_unit(clear_db, run_cli_command, get_pseudo_family, unit):
204+
def test_family_show_unit(aiida_profile_clean, run_cli_command, get_pseudo_family, unit):
203205
"""Test the `-u/--unit` option."""
204206
elements = [
205207
'Ar',

tests/cli/test_install.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def _run_monkeypatched_install_pseudo_dojo(options=None, raises=None):
147147
return _run_monkeypatched_install_pseudo_dojo
148148

149149

150-
@pytest.mark.usefixtures('clear_db')
150+
@pytest.mark.usefixtures('aiida_profile_clean')
151151
def test_install_family(run_cli_command, get_pseudo_archive):
152152
"""Test ``aiida-pseudo install family``."""
153153
label = 'family'
@@ -165,7 +165,7 @@ def test_install_family(run_cli_command, get_pseudo_archive):
165165
assert len(family.pseudos) != 0
166166

167167

168-
@pytest.mark.usefixtures('clear_db')
168+
@pytest.mark.usefixtures('aiida_profile_clean')
169169
def test_install_family_folder(run_cli_command, filepath_pseudos):
170170
"""Test ``aiida-pseudo install family` from folder`."""
171171
label = 'family_test'
@@ -183,7 +183,7 @@ def test_install_family_folder(run_cli_command, filepath_pseudos):
183183
assert len(family.pseudos) != 0
184184

185185

186-
@pytest.mark.usefixtures('clear_db')
186+
@pytest.mark.usefixtures('aiida_profile_clean')
187187
def test_install_family_url(run_cli_command, get_pseudo_archive, monkeypatch):
188188
"""Test ``aiida-pseudo install family`` when installing from a URL.
189189
@@ -222,7 +222,7 @@ def convert(*_, **__):
222222
assert len(family.pseudos) != 0
223223

224224

225-
@pytest.mark.usefixtures('clear_db')
225+
@pytest.mark.usefixtures('aiida_profile_clean')
226226
def test_install_sssp(run_cli_command):
227227
"""Test the ``aiida-pseudo install sssp`` command."""
228228
from aiida_pseudo import __version__
@@ -241,7 +241,7 @@ def test_install_sssp(run_cli_command):
241241
assert 'is already installed' in result.output
242242

243243

244-
@pytest.mark.usefixtures('clear_db')
244+
@pytest.mark.usefixtures('aiida_profile_clean')
245245
def test_install_pseudo_dojo(run_cli_command):
246246
"""Test the ``aiida-pseudo install pseudo-dojo`` command."""
247247
from aiida_pseudo import __version__
@@ -260,7 +260,7 @@ def test_install_pseudo_dojo(run_cli_command):
260260
assert 'is already installed' in result.output
261261

262262

263-
@pytest.mark.usefixtures('clear_db')
263+
@pytest.mark.usefixtures('aiida_profile_clean')
264264
def test_install_sssp_monkeypatched(run_monkeypatched_install_sssp):
265265
"""Test the ``aiida-pseudo install sssp`` command with a monkeypatched download function.
266266
@@ -283,7 +283,7 @@ def test_install_sssp_monkeypatched(run_monkeypatched_install_sssp):
283283
assert family.label == label
284284

285285

286-
@pytest.mark.usefixtures('clear_db')
286+
@pytest.mark.usefixtures('aiida_profile_clean')
287287
@pytest.mark.filterwarnings('ignore:filename .* does not have a supported extension.:UserWarning')
288288
def test_install_pseudo_dojo_monkeypatched(run_monkeypatched_install_pseudo_dojo):
289289
"""Test the ``aiida-pseudo install pseudo-dojo`` command with a monkeypatched download function.
@@ -308,7 +308,7 @@ def test_install_pseudo_dojo_monkeypatched(run_monkeypatched_install_pseudo_dojo
308308
assert family.label == label
309309

310310

311-
@pytest.mark.usefixtures('clear_db', 'chdir_tmp_path')
311+
@pytest.mark.usefixtures('aiida_profile_clean', 'chdir_tmp_path')
312312
def test_install_sssp_download_only(run_monkeypatched_install_sssp):
313313
"""Test the ``aiida-pseudo install sssp`` command with the ``--download-only`` option.
314314
@@ -328,7 +328,7 @@ def test_install_sssp_download_only(run_monkeypatched_install_sssp):
328328
assert 'Success: Pseudopotential archive written to:' in result.output
329329

330330

331-
@pytest.mark.usefixtures('clear_db', 'chdir_tmp_path')
331+
@pytest.mark.usefixtures('aiida_profile_clean', 'chdir_tmp_path')
332332
def test_install_sssp_download_only_exists(run_monkeypatched_install_sssp, get_pseudo_family):
333333
"""Test the ``aiida-pseudo install sssp`` command with the ``--download-only`` option.
334334
@@ -350,7 +350,7 @@ def test_install_sssp_download_only_exists(run_monkeypatched_install_sssp, get_p
350350

351351

352352
@pytest.mark.parametrize('configuration', SsspFamily.valid_configurations)
353-
@pytest.mark.usefixtures('clear_db', 'chdir_tmp_path')
353+
@pytest.mark.usefixtures('aiida_profile_clean', 'chdir_tmp_path')
354354
def test_install_sssp_from_download(run_monkeypatched_install_sssp, configuration):
355355
"""Test the ``aiida-pseudo install sssp`` command with the ``--from-download`` option."""
356356
options = [
@@ -373,7 +373,7 @@ def test_install_sssp_from_download(run_monkeypatched_install_sssp, configuratio
373373
assert 'Success: installed `SSSP/' in result.output
374374

375375

376-
@pytest.mark.usefixtures('clear_db', 'chdir_tmp_path')
376+
@pytest.mark.usefixtures('aiida_profile_clean', 'chdir_tmp_path')
377377
def test_install_pseudo_dojo_download_only(run_monkeypatched_install_pseudo_dojo):
378378
"""Test the ``aiida-pseudo install pseudo-dojo`` command with the ``--download-only`` option.
379379
@@ -393,7 +393,7 @@ def test_install_pseudo_dojo_download_only(run_monkeypatched_install_pseudo_dojo
393393
assert 'Success: Pseudopotential archive written to:' in result.output
394394

395395

396-
@pytest.mark.usefixtures('clear_db', 'chdir_tmp_path')
396+
@pytest.mark.usefixtures('aiida_profile_clean', 'chdir_tmp_path')
397397
def test_install_pseudo_dojo_download_only_exists(run_monkeypatched_install_pseudo_dojo, get_pseudo_family):
398398
"""Test the ``aiida-pseudo install pseudo_dojo`` command with the ``--download-only`` option.
399399
@@ -429,7 +429,7 @@ def test_install_pseudo_dojo_download_only_exists(run_monkeypatched_install_pseu
429429
assert 'Success: Pseudopotential archive written to:' in result.output
430430

431431

432-
@pytest.mark.usefixtures('clear_db', 'chdir_tmp_path')
432+
@pytest.mark.usefixtures('aiida_profile_clean', 'chdir_tmp_path')
433433
def test_install_pseudo_dojo_from_download(run_monkeypatched_install_pseudo_dojo):
434434
"""Test the ``aiida-pseudo install pseudo-dojo`` command with the ``--from-download`` option."""
435435
version = '1.0'

tests/cli/test_list.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from aiida_pseudo.groups.family import PseudoPotentialFamily, SsspFamily
66

77

8-
def test_list(clear_db, run_cli_command, get_pseudo_family):
8+
def test_list(aiida_profile_clean, run_cli_command, get_pseudo_family):
99
"""Test the `aiida-pseudo list` command."""
1010
result = run_cli_command(cmd_list)
1111
assert 'no pseudo potential families have been installed yet: use `aiida-pseudo install`.' in result.output
@@ -17,7 +17,7 @@ def test_list(clear_db, run_cli_command, get_pseudo_family):
1717
assert family.label in result.output
1818

1919

20-
def test_list_raw(clear_db, run_cli_command, get_pseudo_family):
20+
def test_list_raw(aiida_profile_clean, run_cli_command, get_pseudo_family):
2121
"""Test the `-r/--raw` option."""
2222
get_pseudo_family()
2323

@@ -26,7 +26,7 @@ def test_list_raw(clear_db, run_cli_command, get_pseudo_family):
2626
assert len(result.output_lines) == 1
2727

2828

29-
def test_list_project(clear_db, run_cli_command, get_pseudo_family):
29+
def test_list_project(aiida_profile_clean, run_cli_command, get_pseudo_family):
3030
"""Test the `-p/--project` option."""
3131
family = get_pseudo_family()
3232

@@ -39,7 +39,7 @@ def test_list_project(clear_db, run_cli_command, get_pseudo_family):
3939
assert family.label in result.output
4040

4141

42-
def test_list_filter(clear_db, run_cli_command, get_pseudo_family):
42+
def test_list_filter(aiida_profile_clean, run_cli_command, get_pseudo_family):
4343
"""Test the filtering option `-F`."""
4444
family_base = get_pseudo_family(label='Pseudo potential family', cls=PseudoPotentialFamily)
4545
family_sssp = get_pseudo_family(label='SSSP/1.0/PBE/efficiency', cls=SsspFamily, pseudo_type=UpfData)
@@ -57,7 +57,7 @@ def test_list_filter(clear_db, run_cli_command, get_pseudo_family):
5757
assert family_sssp.label in result.output
5858

5959

60-
def test_list_filter_no_result(clear_db, run_cli_command, get_pseudo_family):
60+
def test_list_filter_no_result(aiida_profile_clean, run_cli_command, get_pseudo_family):
6161
"""Test the filtering option `-F` for a type for which no families exist."""
6262
get_pseudo_family(label='Pseudo potential family', cls=PseudoPotentialFamily)
6363

tests/cli/test_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from aiida_pseudo.groups.family import PseudoPotentialFamily
99

1010

11-
@pytest.mark.usefixtures('clear_db')
11+
@pytest.mark.usefixtures('aiida_profile_clean')
1212
@pytest.mark.parametrize(('fmt',), [(fmt[0],) for fmt in shutil.get_archive_formats()])
1313
def test_create_family_from_archive(get_pseudo_archive, fmt):
1414
"""Test the `create_family_from_archive` utility function."""
@@ -21,14 +21,14 @@ def test_create_family_from_archive(get_pseudo_archive, fmt):
2121
assert family.count() != 0
2222

2323

24-
@pytest.mark.usefixtures('clear_db')
24+
@pytest.mark.usefixtures('aiida_profile_clean')
2525
def test_create_family_from_archive_incorrect_filetype(tmp_path):
2626
"""Test the `create_family_from_archive` utility function for incorrect archive filetype."""
2727
with pytest.raises(OSError, match=r'failed to unpack the archive.*'):
2828
create_family_from_archive(PseudoPotentialFamily, 'label', tmp_path)
2929

3030

31-
@pytest.mark.usefixtures('clear_db')
31+
@pytest.mark.usefixtures('aiida_profile_clean')
3232
def test_create_family_from_archive_incorrect_format(tmp_path):
3333
"""Test the `create_family_from_archive` utility function for invalid archive content."""
3434
with tempfile.NamedTemporaryFile(suffix='.tar.gz') as filepath_archive:

tests/conftest.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@
1111
from aiida_pseudo.data.pseudo import PseudoPotentialData
1212
from aiida_pseudo.groups.family import CutoffsPseudoPotentialFamily, PseudoPotentialFamily
1313

14-
pytest_plugins = ['aiida.manage.tests.pytest_fixtures']
15-
16-
17-
@pytest.fixture
18-
def clear_db(aiida_profile_clean):
19-
"""Alias for the `aiida_profile_clean` fixture from `aiida-core`."""
20-
yield
14+
pytest_plugins = 'aiida.tools.pytest_fixtures'
2115

2216

2317
@pytest.fixture

tests/data/pseudo/test_jthxml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_constructor(filepath_pseudos):
3939
assert pseudo.element == filepath.name.split('.')[0]
4040

4141

42-
@pytest.mark.usefixtures('clear_db')
42+
@pytest.mark.usefixtures('aiida_profile_clean')
4343
def test_set_file(filepath_pseudos, get_pseudo_potential_data):
4444
"""Test the `JthXmlData.set_file` method.
4545

tests/data/pseudo/test_pseudo.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def test_prepare_source(source):
9898
assert PseudoPotentialData.prepare_source(source) is source
9999

100100

101-
@pytest.mark.usefixtures('clear_db')
101+
@pytest.mark.usefixtures('aiida_profile_clean')
102102
def test_store():
103103
"""Test the `PseudoPotentialData.store` method."""
104104
stream = io.BytesIO(b'pseudo')
@@ -123,7 +123,7 @@ def test_store():
123123
assert pseudo.is_stored
124124

125125

126-
@pytest.mark.usefixtures('clear_db')
126+
@pytest.mark.usefixtures('aiida_profile_clean')
127127
def test_element():
128128
"""Test the `PseudoPotentialData.element` property."""
129129
element = 'Ar'
@@ -143,7 +143,7 @@ def test_element():
143143
pseudo.element = element
144144

145145

146-
@pytest.mark.usefixtures('clear_db')
146+
@pytest.mark.usefixtures('aiida_profile_clean')
147147
def test_md5():
148148
"""Test the `PseudoPotentialData.md5` property."""
149149
stream = io.BytesIO(b'pseudo')
@@ -163,7 +163,7 @@ def test_md5():
163163
pseudo.md5 = md5
164164

165165

166-
@pytest.mark.usefixtures('clear_db')
166+
@pytest.mark.usefixtures('aiida_profile_clean')
167167
def test_store_indirect():
168168
"""Test the `PseudoPotentialData.store` method when called indirectly because its is an input."""
169169
pseudo = PseudoPotentialData(io.BytesIO(b'pseudo'))
@@ -174,7 +174,7 @@ def test_store_indirect():
174174
node.store_all()
175175

176176

177-
@pytest.mark.usefixtures('clear_db')
177+
@pytest.mark.usefixtures('aiida_profile_clean')
178178
def test_get_or_create(get_pseudo_potential_data):
179179
"""Test the ``PseudoPotentialData.get_or_create`` classmethod."""
180180
upf = get_pseudo_potential_data(entry_point='upf')

tests/data/pseudo/test_psf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_constructor(filepath_pseudos):
5656
assert pseudo.element == filepath.name.split('.')[0]
5757

5858

59-
@pytest.mark.usefixtures('clear_db')
59+
@pytest.mark.usefixtures('aiida_profile_clean')
6060
def test_set_file(filepath_pseudos, get_pseudo_potential_data):
6161
"""Test the `PsfData.set_file` method.
6262

0 commit comments

Comments
 (0)