From f4f3cfac64df1de9ca33499ed871ae096db0fd76 Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Fri, 21 Jun 2024 13:45:24 +0200 Subject: [PATCH] More sophisticate pytest running option. --- .github/workflows/ci.yml | 35 +++++++++++++++---- tests/utils/test_structure.py | 4 ++- .../test_get_standard_structure_Fe_BCC_.yml | 23 +++++------- .../test_get_standard_structure_Fe_DC_.yml | 29 +++++++-------- .../test_get_standard_structure_Fe_GS_.yml | 27 +++++++------- .../test_get_standard_structure_La_DC_.yml | 29 +++++++-------- .../test_get_standard_structure_La_LAN_.yml | 29 +++++++-------- .../test_get_standard_structure_La_XO_.yml | 29 +++++++-------- .../test_get_standard_structure_Te_DC_.yml | 29 +++++++-------- .../test_get_standard_structure_Te_GS_.yml | 34 +++++++++--------- 10 files changed, 135 insertions(+), 133 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4e9b208..26c07109 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,11 +7,18 @@ on: [push, pull_request] jobs: - fast-tests: + fast-tests: runs-on: ubuntu-latest timeout-minutes: 10 + services: + rabbitmq: + image: rabbitmq:3.8.14-management + ports: + - 5672:5672 + - 15672:15672 + steps: - uses: actions/checkout@v4 @@ -24,9 +31,9 @@ jobs: run: | pip install .[dev] - - name: Pull the image and Run pytest + - name: Run pytest run: | - pytest -v tests -m "not slow" + pytest -s tests -m "not slow" slow-tests: @@ -34,6 +41,13 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 + services: + rabbitmq: + image: rabbitmq:3.8.14-management + ports: + - 5672:5672 + - 15672:15672 + steps: - uses: actions/checkout@v4 @@ -46,9 +60,9 @@ jobs: run: | pip install .[dev] - - name: Pull the image and Run pytest + - name: Run pytest run: | - pytest -v tests -m "slow" + pytest -s tests -m "slow" edge-aiida-core-tests: # This is to test the plugin is compatible with the main branch of aiida-core @@ -57,6 +71,13 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 + services: + rabbitmq: + image: rabbitmq:3.8.14-management + ports: + - 5672:5672 + - 15672:15672 + steps: - uses: actions/checkout@v4 @@ -81,6 +102,6 @@ jobs: exit 1 fi - - name: Pull the image and Run pytest + - name: Run pytest run: | - pytest -v tests + pytest -s tests diff --git a/tests/utils/test_structure.py b/tests/utils/test_structure.py index e6444456..1047acfe 100644 --- a/tests/utils/test_structure.py +++ b/tests/utils/test_structure.py @@ -1,5 +1,6 @@ import pytest import itertools +import numpy as np from aiida.engine import run_get_node from aiida import orm @@ -47,8 +48,9 @@ def test_get_standard_structure(element, configuration, data_regression): r, _ = run_get_node( get_standard_structure, element=element, configuration=configuration ) + ase_r = r.get_ase() - data_regression.check(r.get_cif().get_content()) + data_regression.check({k: np.round(v, 3).tolist() for k, v in ase_r.arrays.items()}) @pytest.mark.parametrize( diff --git a/tests/utils/test_structure/test_get_standard_structure_Fe_BCC_.yml b/tests/utils/test_structure/test_get_standard_structure_Fe_BCC_.yml index edca5ed9..93315bdd 100644 --- a/tests/utils/test_structure/test_get_standard_structure_Fe_BCC_.yml +++ b/tests/utils/test_structure/test_get_standard_structure_Fe_BCC_.yml @@ -1,15 +1,8 @@ -"\n##########################################################################\n# \ - \ Crystallographic Information Format file\n# Produced\ - \ by PyCifRW module\n#\n# This is a CIF file. CIF has been adopted by the International\n\ - # Union of Crystallography as the standard for data archiving and\n# transmission.\n\ - #\n# For information on this file format, follow the CIF links at\n# http://www.iucr.org\n\ - ##########################################################################\n\ndata_0\n\ - \nloop_\n _atom_site_label\n _atom_site_fract_x\n _atom_site_fract_y\n _atom_site_fract_z\n\ - \ _atom_site_type_symbol\n Fe1 0.0 0.0 0.0 Fe \n\ - _cell_angle_alpha 109.47122063449069\n_cell_angle_beta \ - \ 109.47122063449069\n_cell_angle_gamma \ - \ 109.47122063449069\n_cell_length_a 2.389785699289135\n\ - _cell_length_b 2.389785699289135\n_cell_length_c \ - \ 2.389785699289135\nloop_\n _symmetry_equiv_pos_as_xyz\n \ - \ 'x, y, z' \n_symmetry_int_tables_number 1\n_symmetry_space_group_name_H-M\ - \ 'P 1'" +masses: +- 55.845 +numbers: +- 26 +positions: +- - 0.0 + - 0.0 + - 0.0 diff --git a/tests/utils/test_structure/test_get_standard_structure_Fe_DC_.yml b/tests/utils/test_structure/test_get_standard_structure_Fe_DC_.yml index 733f709e..63332bd5 100644 --- a/tests/utils/test_structure/test_get_standard_structure_Fe_DC_.yml +++ b/tests/utils/test_structure/test_get_standard_structure_Fe_DC_.yml @@ -1,16 +1,13 @@ -"\n##########################################################################\n# \ - \ Crystallographic Information Format file\n# Produced\ - \ by PyCifRW module\n#\n# This is a CIF file. CIF has been adopted by the International\n\ - # Union of Crystallography as the standard for data archiving and\n# transmission.\n\ - #\n# For information on this file format, follow the CIF links at\n# http://www.iucr.org\n\ - ##########################################################################\n\ndata_0\n\ - \nloop_\n _atom_site_label\n _atom_site_fract_x\n _atom_site_fract_y\n _atom_site_fract_z\n\ - \ _atom_site_type_symbol\n Fe1 0.0 0.0 0.0 Fe \ - \ \n Fe2 0.24999999999998976 0.24999999999998976 \ - \ 0.24999999999998976 Fe\n_cell_angle_alpha \ - \ 60.00000000000001\n_cell_angle_beta 60.00000000000001\n\ - _cell_angle_gamma 60.00000000000001\n_cell_length_a \ - \ 3.4460197248582936\n_cell_length_b \ - \ 3.4460197248582936\n_cell_length_c 3.4460197248582936\n\ - loop_\n _symmetry_equiv_pos_as_xyz\n 'x, y, z' \n_symmetry_int_tables_number\ - \ 1\n_symmetry_space_group_name_H-M 'P 1'" +masses: +- 55.845 +- 55.845 +numbers: +- 26 +- 26 +positions: +- - 0.0 + - 0.0 + - 0.0 +- - 1.218 + - 1.218 + - 1.218 diff --git a/tests/utils/test_structure/test_get_standard_structure_Fe_GS_.yml b/tests/utils/test_structure/test_get_standard_structure_Fe_GS_.yml index 34d28048..6f6ae02f 100644 --- a/tests/utils/test_structure/test_get_standard_structure_Fe_GS_.yml +++ b/tests/utils/test_structure/test_get_standard_structure_Fe_GS_.yml @@ -1,14 +1,13 @@ -"\n##########################################################################\n# \ - \ Crystallographic Information Format file\n# Produced\ - \ by PyCifRW module\n#\n# This is a CIF file. CIF has been adopted by the International\n\ - # Union of Crystallography as the standard for data archiving and\n# transmission.\n\ - #\n# For information on this file format, follow the CIF links at\n# http://www.iucr.org\n\ - ##########################################################################\n\ndata_0\n\ - \nloop_\n _atom_site_label\n _atom_site_fract_x\n _atom_site_fract_y\n _atom_site_fract_z\n\ - \ _atom_site_type_symbol\n Fe1 0.0 0.0 0.0 Fe \ - \ \n Fe2 0.5 0.5 0.5 Fe \n_cell_angle_alpha\ - \ 90.0\n_cell_angle_beta 90.0\n_cell_angle_gamma\ - \ 90.0\n_cell_length_a 2.83351\n\ - _cell_length_b 2.83351\n_cell_length_c \ - \ 2.83351\nloop_\n _symmetry_equiv_pos_as_xyz\n 'x, y, z' \n_symmetry_int_tables_number\ - \ 1\n_symmetry_space_group_name_H-M 'P 1'" +masses: +- 55.845 +- 55.845 +numbers: +- 26 +- 26 +positions: +- - 0.0 + - 0.0 + - 0.0 +- - 1.417 + - 1.417 + - 1.417 diff --git a/tests/utils/test_structure/test_get_standard_structure_La_DC_.yml b/tests/utils/test_structure/test_get_standard_structure_La_DC_.yml index 03baa50c..a908053e 100644 --- a/tests/utils/test_structure/test_get_standard_structure_La_DC_.yml +++ b/tests/utils/test_structure/test_get_standard_structure_La_DC_.yml @@ -1,16 +1,13 @@ -"\n##########################################################################\n# \ - \ Crystallographic Information Format file\n# Produced\ - \ by PyCifRW module\n#\n# This is a CIF file. CIF has been adopted by the International\n\ - # Union of Crystallography as the standard for data archiving and\n# transmission.\n\ - #\n# For information on this file format, follow the CIF links at\n# http://www.iucr.org\n\ - ##########################################################################\n\ndata_0\n\ - \nloop_\n _atom_site_label\n _atom_site_fract_x\n _atom_site_fract_y\n _atom_site_fract_z\n\ - \ _atom_site_type_symbol\n La1 0.5 0.5 0.5 La \ - \ \n La2 0.75 0.7499999999999998 0.7500000000000001 La\ - \ \n_cell_angle_alpha 59.99999999999999\n_cell_angle_beta\ - \ 59.99999999999999\n_cell_angle_gamma \ - \ 59.99999999999999\n_cell_length_a 4.727360973810436\n\ - _cell_length_b 4.727360973810436\n_cell_length_c \ - \ 4.727360973810436\nloop_\n _symmetry_equiv_pos_as_xyz\n \ - \ 'x, y, z' \n_symmetry_int_tables_number 1\n_symmetry_space_group_name_H-M\ - \ 'P 1'" +masses: +- 138.905 +- 138.905 +numbers: +- 57 +- 57 +positions: +- - 0.0 + - 0.0 + - 3.343 +- - 1.671 + - 5.014 + - 1.671 diff --git a/tests/utils/test_structure/test_get_standard_structure_La_LAN_.yml b/tests/utils/test_structure/test_get_standard_structure_La_LAN_.yml index a206212a..5d604a83 100644 --- a/tests/utils/test_structure/test_get_standard_structure_La_LAN_.yml +++ b/tests/utils/test_structure/test_get_standard_structure_La_LAN_.yml @@ -1,16 +1,13 @@ -"\n##########################################################################\n# \ - \ Crystallographic Information Format file\n# Produced\ - \ by PyCifRW module\n#\n# This is a CIF file. CIF has been adopted by the International\n\ - # Union of Crystallography as the standard for data archiving and\n# transmission.\n\ - #\n# For information on this file format, follow the CIF links at\n# http://www.iucr.org\n\ - ##########################################################################\n\ndata_0\n\ - \nloop_\n _atom_site_label\n _atom_site_fract_x\n _atom_site_fract_y\n _atom_site_fract_z\n\ - \ _atom_site_type_symbol\n La1 0.0 0.0 0.0 La \ - \ \n N1 0.5 0.5 0.5 N \n_cell_angle_alpha\ - \ 59.99999999999999\n_cell_angle_beta \ - \ 59.99999999999999\n_cell_angle_gamma 59.99999999999999\n\ - _cell_length_a 3.758950000000038\n_cell_length_b \ - \ 3.758950000000038\n_cell_length_c \ - \ 3.758950000000038\nloop_\n _symmetry_equiv_pos_as_xyz\n 'x, y, z' \n\ - _symmetry_int_tables_number 1\n_symmetry_space_group_name_H-M \ - \ 'P 1'" +masses: +- 138.905 +- 14.007 +numbers: +- 57 +- 7 +positions: +- - 0.0 + - 0.0 + - 0.0 +- - 0.0 + - 2.658 + - 0.0 diff --git a/tests/utils/test_structure/test_get_standard_structure_La_XO_.yml b/tests/utils/test_structure/test_get_standard_structure_La_XO_.yml index 9a83dda9..b47cecc3 100644 --- a/tests/utils/test_structure/test_get_standard_structure_La_XO_.yml +++ b/tests/utils/test_structure/test_get_standard_structure_La_XO_.yml @@ -1,16 +1,13 @@ -"\n##########################################################################\n# \ - \ Crystallographic Information Format file\n# Produced\ - \ by PyCifRW module\n#\n# This is a CIF file. CIF has been adopted by the International\n\ - # Union of Crystallography as the standard for data archiving and\n# transmission.\n\ - #\n# For information on this file format, follow the CIF links at\n# http://www.iucr.org\n\ - ##########################################################################\n\ndata_0\n\ - \nloop_\n _atom_site_label\n _atom_site_fract_x\n _atom_site_fract_y\n _atom_site_fract_z\n\ - \ _atom_site_type_symbol\n La1 0.0 0.0 0.0 La \ - \ \n O1 0.49999999999999994 0.5 0.5 O\ - \ \n_cell_angle_alpha 59.99999999999999\n_cell_angle_beta\ - \ 59.99999999999999\n_cell_angle_gamma \ - \ 59.99999999999999\n_cell_length_a 3.6515633298742327\n\ - _cell_length_b 3.6515633298742327\n_cell_length_c \ - \ 3.6515633298742327\nloop_\n _symmetry_equiv_pos_as_xyz\n\ - \ 'x, y, z' \n_symmetry_int_tables_number 1\n_symmetry_space_group_name_H-M\ - \ 'P 1'" +masses: +- 138.905 +- 15.999 +numbers: +- 57 +- 8 +positions: +- - 0.0 + - 0.0 + - 0.0 +- - 0.0 + - 2.582 + - 0.0 diff --git a/tests/utils/test_structure/test_get_standard_structure_Te_DC_.yml b/tests/utils/test_structure/test_get_standard_structure_Te_DC_.yml index 48a5fe24..67f6ad30 100644 --- a/tests/utils/test_structure/test_get_standard_structure_Te_DC_.yml +++ b/tests/utils/test_structure/test_get_standard_structure_Te_DC_.yml @@ -1,16 +1,13 @@ -"\n##########################################################################\n# \ - \ Crystallographic Information Format file\n# Produced\ - \ by PyCifRW module\n#\n# This is a CIF file. CIF has been adopted by the International\n\ - # Union of Crystallography as the standard for data archiving and\n# transmission.\n\ - #\n# For information on this file format, follow the CIF links at\n# http://www.iucr.org\n\ - ##########################################################################\n\ndata_0\n\ - \nloop_\n _atom_site_label\n _atom_site_fract_x\n _atom_site_fract_y\n _atom_site_fract_z\n\ - \ _atom_site_type_symbol\n Te1 0.5 0.5 0.5 Te \ - \ \n Te2 0.7499999999999931 0.7499999999999929 0.7499999999999931\ - \ Te\n_cell_angle_alpha 59.99999999999999\n_cell_angle_beta\ - \ 59.99999999999999\n_cell_angle_gamma \ - \ 59.99999999999999\n_cell_length_a 5.082361105318261\n\ - _cell_length_b 5.082361105318261\n_cell_length_c \ - \ 5.082361105318261\nloop_\n _symmetry_equiv_pos_as_xyz\n \ - \ 'x, y, z' \n_symmetry_int_tables_number 1\n_symmetry_space_group_name_H-M\ - \ 'P 1'" +masses: +- 127.6 +- 127.6 +numbers: +- 52 +- 52 +positions: +- - 0.0 + - 0.0 + - 3.594 +- - 1.797 + - 5.391 + - 1.797 diff --git a/tests/utils/test_structure/test_get_standard_structure_Te_GS_.yml b/tests/utils/test_structure/test_get_standard_structure_Te_GS_.yml index 49e034dc..bb74263b 100644 --- a/tests/utils/test_structure/test_get_standard_structure_Te_GS_.yml +++ b/tests/utils/test_structure/test_get_standard_structure_Te_GS_.yml @@ -1,16 +1,18 @@ -"\n##########################################################################\n# \ - \ Crystallographic Information Format file\n# Produced\ - \ by PyCifRW module\n#\n# This is a CIF file. CIF has been adopted by the International\n\ - # Union of Crystallography as the standard for data archiving and\n# transmission.\n\ - #\n# For information on this file format, follow the CIF links at\n# http://www.iucr.org\n\ - ##########################################################################\n\ndata_0\n\ - \nloop_\n _atom_site_label\n _atom_site_fract_x\n _atom_site_fract_y\n _atom_site_fract_z\n\ - \ _atom_site_type_symbol\n Te1 0.7303400000000044 0.7303400000000088\ - \ 0.5 Te \n Te2 0.9999999999999957 0.26965999999999135\ - \ 0.16666666666666666 Te \n Te3 0.26966 \ - \ 0.0 0.8333333333333333 Te \n_cell_angle_alpha 90.0\n\ - _cell_angle_beta 90.0\n_cell_angle_gamma \ - \ 119.99999999999997\n_cell_length_a 4.50788\n_cell_length_b\ - \ 4.507880000000004\n_cell_length_c \ - \ 5.96346\nloop_\n _symmetry_equiv_pos_as_xyz\n 'x, y, z' \n_symmetry_int_tables_number\ - \ 1\n_symmetry_space_group_name_H-M 'P 1'" +masses: +- 127.6 +- 127.6 +- 127.6 +numbers: +- 52 +- 52 +- 52 +positions: +- - 1.646 + - 2.851 + - 2.982 +- - -0.608 + - 1.053 + - 0.994 +- - 1.216 + - 0.0 + - 4.97