Skip to content

Commit

Permalink
Tests: Add aiida_profile_clean where needed or refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sphuber committed Dec 6, 2022
1 parent a4e12b4 commit 1334c52
Show file tree
Hide file tree
Showing 132 changed files with 891 additions and 1,167 deletions.
2 changes: 1 addition & 1 deletion aiida/manage/tests/pytest_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def temp_dir():
shutil.rmtree(dirpath)


@pytest.fixture(scope='function')
@pytest.fixture
def aiida_local_code_factory(aiida_localhost):
"""Get an AiiDA code on localhost.
Expand Down
1 change: 0 additions & 1 deletion tests/benchmark/test_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def get_export_kwargs(**kwargs):


@pytest.mark.parametrize('depth,breadth,num_objects', TREE.values(), ids=TREE.keys())
@pytest.mark.usefixtures('aiida_profile')
@pytest.mark.benchmark(group='import-export')
def test_export(benchmark, tmp_path, depth, breadth, num_objects):
"""Benchmark exporting a provenance graph."""
Expand Down
3 changes: 1 addition & 2 deletions tests/benchmark/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ def run_task(self):


@pytest.mark.parametrize('workchain,iterations,outgoing', WORKCHAINS.values(), ids=WORKCHAINS.keys())
@pytest.mark.usefixtures('aiida_profile')
@pytest.mark.benchmark(group='engine')
def test_workchain_local(benchmark, aiida_localhost, workchain, iterations, outgoing):
"""Benchmark Workchains, executed in the local runner."""
Expand All @@ -130,7 +129,7 @@ def _run():


@pytest.mark.parametrize('workchain,iterations,outgoing', WORKCHAINS.values(), ids=WORKCHAINS.keys())
@pytest.mark.usefixtures('aiida_profile', 'started_daemon_client')
@pytest.mark.usefixtures('started_daemon_client')
@pytest.mark.benchmark(group='engine')
def test_workchain_daemon(benchmark, submit_and_await, aiida_localhost, workchain, iterations, outgoing):
"""Benchmark Workchains, executed in the via a daemon runner."""
Expand Down
6 changes: 0 additions & 6 deletions tests/benchmark/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def get_data_node_and_object(store=True):
return (), {'node': data}


@pytest.mark.usefixtures('aiida_profile')
@pytest.mark.benchmark(group=GROUP_NAME, min_rounds=100)
def test_store_backend(benchmark):
"""Benchmark for creating and storing a node directly,
Expand All @@ -59,7 +58,6 @@ def _run():
assert node.is_stored, node


@pytest.mark.usefixtures('aiida_profile')
@pytest.mark.benchmark(group=GROUP_NAME, min_rounds=100)
def test_store(benchmark):
"""Benchmark for creating and storing a node,
Expand All @@ -69,7 +67,6 @@ def test_store(benchmark):
assert node_dict['node'].is_stored, node_dict


@pytest.mark.usefixtures('aiida_profile')
@pytest.mark.benchmark(group=GROUP_NAME, min_rounds=100)
def test_store_with_object(benchmark):
"""Benchmark for creating and storing a node,
Expand All @@ -79,7 +76,6 @@ def test_store_with_object(benchmark):
assert node_dict['node'].is_stored, node_dict


@pytest.mark.usefixtures('aiida_profile')
@pytest.mark.benchmark(group=GROUP_NAME)
def test_delete_backend(benchmark):
"""Benchmark for deleting a stored node directly,
Expand All @@ -96,7 +92,6 @@ def _run(node):
load_node(pk)


@pytest.mark.usefixtures('aiida_profile')
@pytest.mark.benchmark(group=GROUP_NAME)
def test_delete(benchmark):
"""Benchmark for deleting a node,
Expand All @@ -113,7 +108,6 @@ def _run(node):
load_node(pk)


@pytest.mark.usefixtures('aiida_profile')
@pytest.mark.benchmark(group=GROUP_NAME)
def test_delete_with_object(benchmark):
"""Benchmark for deleting a node,
Expand Down
3 changes: 0 additions & 3 deletions tests/calculations/arithmetic/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


@pytest.mark.requires_rmq
@pytest.mark.usefixtures('aiida_profile')
def test_add_default(fixture_sandbox, aiida_localhost, generate_calc_job):
"""Test a default `ArithmeticAddCalculation`."""
inputs = {
Expand Down Expand Up @@ -48,7 +47,6 @@ def test_add_default(fixture_sandbox, aiida_localhost, generate_calc_job):


@pytest.mark.requires_rmq
@pytest.mark.usefixtures('aiida_profile')
def test_add_custom_filenames(fixture_sandbox, aiida_localhost, generate_calc_job):
"""Test an `ArithmeticAddCalculation` with non-default input and output filenames."""
input_filename = 'custom.in'
Expand All @@ -74,7 +72,6 @@ def test_add_custom_filenames(fixture_sandbox, aiida_localhost, generate_calc_jo


@pytest.mark.requires_rmq
@pytest.mark.usefixtures('aiida_profile')
def test_sleep(fixture_sandbox, aiida_localhost, generate_calc_job):
"""Test the ``metadata.options.sleep`` input."""
sleep = 5
Expand Down
2 changes: 0 additions & 2 deletions tests/calculations/test_templatereplacer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


@pytest.mark.requires_rmq
@pytest.mark.usefixtures('aiida_profile')
def test_base_template(fixture_sandbox, aiida_localhost, generate_calc_job):
"""Test a base template that emulates the arithmetic add."""

Expand Down Expand Up @@ -73,7 +72,6 @@ def test_base_template(fixture_sandbox, aiida_localhost, generate_calc_job):


@pytest.mark.requires_rmq
@pytest.mark.usefixtures('aiida_profile')
def test_file_usage(fixture_sandbox, aiida_localhost, generate_calc_job):
"""Test a base template that uses two files."""

Expand Down
2 changes: 0 additions & 2 deletions tests/calculations/test_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


@pytest.mark.requires_rmq
@pytest.mark.usefixtures('aiida_profile')
def test_get_transfer(fixture_sandbox, aiida_localhost, generate_calc_job, tmp_path):
"""Test a default `TransferCalculation`."""

Expand Down Expand Up @@ -67,7 +66,6 @@ def test_get_transfer(fixture_sandbox, aiida_localhost, generate_calc_job, tmp_p


@pytest.mark.requires_rmq
@pytest.mark.usefixtures('aiida_profile')
def test_put_transfer(fixture_sandbox, aiida_localhost, generate_calc_job, tmp_path):
"""Test a default `TransferCalculation`."""

Expand Down
28 changes: 8 additions & 20 deletions tests/cmdline/commands/test_archive_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
###########################################################################
"""Tests for `verdi archive`."""
import shutil
import uuid
import zipfile

import pytest
Expand Down Expand Up @@ -36,18 +37,12 @@ def test_create_force(run_cli_command, tmp_path):
run_cli_command(cmd_archive.create, options)


@pytest.mark.usefixtures('aiida_profile')
def test_create_all(run_cli_command, tmp_path):
@pytest.mark.usefixtures('aiida_profile_clean')
def test_create_all(run_cli_command, tmp_path, aiida_localhost):
"""Test that creating an archive for a set of various ORM entities works with the zip format."""
computer = Computer(
label='comp',
hostname='localhost',
transport_type='core.local',
scheduler_type='core.direct',
workdir='/tmp/aiida'
).store()
computer = aiida_localhost
code = InstalledCode(computer=computer, filepath_executable='/bin/true').store()
group = Group(label='test_group').store()
group = Group(label=str(uuid.uuid4())).store()
filename_output = tmp_path / 'archive.aiida'

options = ['--all', filename_output]
Expand All @@ -60,18 +55,11 @@ def test_create_all(run_cli_command, tmp_path):
assert archive.querybuilder().append(Group, project=['uuid']).all(flat=True) == [group.uuid]


@pytest.mark.usefixtures('aiida_profile')
def test_create_basic(run_cli_command, tmp_path):
def test_create_basic(run_cli_command, tmp_path, aiida_localhost):
"""Test that creating an archive for a set of various ORM entities works with the zip format."""
computer = Computer(
label='comp',
hostname='localhost',
transport_type='core.local',
scheduler_type='core.direct',
workdir='/tmp/aiida'
).store()
computer = aiida_localhost
code = InstalledCode(computer=computer, filepath_executable='/bin/true').store()
group = Group(label='test_group').store()
group = Group(label=str(uuid.uuid4())).store()
node = Dict().store()
filename_output = tmp_path / 'archive.aiida'

Expand Down
3 changes: 1 addition & 2 deletions tests/cmdline/commands/test_archive_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_import_make_new_group(run_cli_command, newest_archive):
assert not group.is_empty, 'The Group should not be empty.'


@pytest.mark.usefixtures('aiida_profile')
@pytest.mark.usefixtures('aiida_profile_clean')
def test_no_import_group(run_cli_command, newest_archive):
"""Test '--import-group/--no-import-group' options."""
archives = [get_archive_file(newest_archive, filepath=ARCHIVE_PATH)]
Expand Down Expand Up @@ -216,7 +216,6 @@ def test_migration(run_cli_command):
assert success_message not in result.output, result.exception


@pytest.mark.usefixtures('aiida_profile')
@pytest.mark.parametrize('version', [v for v in list_versions() if v not in ('main_0000a', 'main_0000b')])
def test_import_old_local_archives(version, run_cli_command):
""" Test import of old local archives
Expand Down
2 changes: 1 addition & 1 deletion tests/cmdline/commands/test_calcjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TestVerdiCalculation:
"""Tests for `verdi calcjob`."""

@pytest.fixture(autouse=True)
def init_profile(self, aiida_profile, aiida_localhost): # pylint: disable=unused-argument
def init_profile(self, aiida_profile_clean, aiida_localhost): # pylint: disable=unused-argument
"""Initialize the profile."""
# pylint: disable=attribute-defined-outside-init

Expand Down
Loading

0 comments on commit 1334c52

Please sign in to comment.