Skip to content

Commit

Permalink
Merge branch 'ph/exit-codes' of https://github.com/bastonero/aiida-qu…
Browse files Browse the repository at this point in the history
…antumespresso into ph/exit-codes
  • Loading branch information
bastonero committed Mar 27, 2024
2 parents aa456ff + 10a88e4 commit 3ce5821
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/aiida_quantumespresso/cli/data/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def cmd_import(filename, dry_run):
"""Import a `StructureData` from a Quantum ESPRESSO input file."""
from aiida_quantumespresso.tools.pwinputparser import PwInputFile

with open(filename, 'r', encoding='utf-8') as input_file:
parser = PwInputFile(input_file.read())
parser = PwInputFile(filename.read())
structure = parser.get_structuredata()
formula = structure.get_formula()

Expand Down
2 changes: 1 addition & 1 deletion tests/cli/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def mock_launch_process(*_, **__):
"""Mock the :meth:`~aiida_quantumespresso.cli.utilslaunch.launch_process` to be a no-op."""
"""Mock the :meth:`~aiida_quantumespresso.cli.utils.launch.launch_process` to be a no-op."""
return


Expand Down
23 changes: 23 additions & 0 deletions tests/cli/data/test_structure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
"""Tests for the ``data structure import`` command."""
from pathlib import Path
import re

import pytest

from aiida_quantumespresso.cli.data.structure import cmd_import


@pytest.mark.usefixtures('aiida_profile')
def test_command_import(run_cli_command, filepath_tests):
"""Test invoking the calculation launch command with only required inputs."""
filepath = str(Path(filepath_tests, 'cli', 'fixtures', 'pw.in').absolute())
options = [filepath]
result = run_cli_command(cmd_import, options=options)
match = r'.*parsed and stored StructureData<(\d+)> with formula (.+?)'
assert re.match(match, ' '.join(result.output_lines))

options = [filepath, '--dry-run']
result = run_cli_command(cmd_import, options=options)
match = r'.*parsed structure with formula (.+?)'
assert re.match(match, ' '.join(result.output_lines))
38 changes: 38 additions & 0 deletions tests/cli/fixtures/pw.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
&CONTROL
calculation = 'scf'
etot_conv_thr = 2.0000000000d-05
forc_conv_thr = 1.0000000000d-04
outdir = './out/'
prefix = 'aiida'
pseudo_dir = './pseudo/'
tprnfor = .true.
tstress = .true.
verbosity = 'high'
/
&SYSTEM
degauss = 1.4699723600d-02
ecutrho = 2.4000000000d+02
ecutwfc = 3.0000000000d+01
ibrav = 0
nat = 2
nosym = .false.
ntyp = 1
occupations = 'smearing'
smearing = 'cold'
/
&ELECTRONS
conv_thr = 4.0000000000d-10
electron_maxstep = 80
mixing_beta = 4.0000000000d-01
/
ATOMIC_SPECIES
Si 28.0855 Si.pbesol-n-rrkjus_psl.1.0.0.UPF
ATOMIC_POSITIONS crystal
Si 0.0000000000 0.0000000000 0.0000000000
Si 0.2500000000 0.2500000000 0.2500000000
K_POINTS automatic
11 11 11 0 0 0
CELL_PARAMETERS angstrom
2.7154800000 2.7154800000 0.0000000000
2.7154800000 0.0000000000 2.7154800000
0.0000000000 2.7154800000 2.7154800000

0 comments on commit 3ce5821

Please sign in to comment.