diff --git a/README.md b/README.md index 786c85e..116fd27 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -[![Build Status](https://github.com/aiidateam/aiida-testing/workflows/ci/badge.svg)](https://github.com/aiidateam/aiida-testing/actions) -[![Docs status](https://readthedocs.org/projects/aiida-testing/badge)](http://aiida-testing.readthedocs.io/) -[![PyPI version](https://badge.fury.io/py/aiida-testing.svg)](https://badge.fury.io/py/aiida-testing) -[![GitHub license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/aiidateam/aiida-testing/blob/main/LICENSE) +[![Build Status](https://github.com/aiidateam/aiida-test-cache/workflows/ci/badge.svg)](https://github.com/aiidateam/aiida-test-cache/actions) +[![Docs status](https://readthedocs.org/projects/aiida-test-cache/badge)](https://aiida-test-cache.readthedocs.io/) +[![PyPI version](https://badge.fury.io/py/aiida-test-cache.svg)](https://badge.fury.io/py/aiida-test-cache) +[![GitHub license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/aiidateam/aiida-test-cache/blob/main/LICENSE) -# aiida-testing +# aiida-test-cache A pytest plugin to simplify testing of AiiDA plugins. This package implements two ways of running an AiiDA calculation in tests: - `mock_code`: Implements a caching layer at the level of the executable called by an AiiDA calculation. This tests the input generation and output parsing, which is useful when testing calculation and parser plugins. - `archive_cache`: Implements an automatic archive creation and loading, to enable AiiDA - level caching in tests. This circumvents the input generation / output parsing, making it suitable for testing higher-level workflows. -For more information, see the [documentation](http://aiida-testing.readthedocs.io/). +For more information, see the [documentation](http://aiida-test-cache.readthedocs.io/). diff --git a/aiida_testing/__init__.py b/aiida_test_cache/__init__.py similarity index 100% rename from aiida_testing/__init__.py rename to aiida_test_cache/__init__.py diff --git a/aiida_testing/_config.py b/aiida_test_cache/_config.py similarity index 98% rename from aiida_testing/_config.py rename to aiida_test_cache/_config.py index 50f1564..cecfe05 100644 --- a/aiida_testing/_config.py +++ b/aiida_test_cache/_config.py @@ -24,7 +24,7 @@ class ConfigActions(Enum): class Config(collections.abc.MutableMapping): - """Configuration of aiida-testing package.""" + """Configuration of aiida-test-cache package.""" schema = Schema({ 'mock_code': Schema({str: str}), diff --git a/aiida_testing/archive_cache/__init__.py b/aiida_test_cache/archive_cache/__init__.py similarity index 100% rename from aiida_testing/archive_cache/__init__.py rename to aiida_test_cache/archive_cache/__init__.py diff --git a/aiida_testing/archive_cache/_fixtures.py b/aiida_test_cache/archive_cache/_fixtures.py similarity index 100% rename from aiida_testing/archive_cache/_fixtures.py rename to aiida_test_cache/archive_cache/_fixtures.py diff --git a/aiida_testing/archive_cache/_utils.py b/aiida_test_cache/archive_cache/_utils.py similarity index 100% rename from aiida_testing/archive_cache/_utils.py rename to aiida_test_cache/archive_cache/_utils.py diff --git a/aiida_testing/mock_code/__init__.py b/aiida_test_cache/mock_code/__init__.py similarity index 86% rename from aiida_testing/mock_code/__init__.py rename to aiida_test_cache/mock_code/__init__.py index 653657b..b51858a 100644 --- a/aiida_testing/mock_code/__init__.py +++ b/aiida_test_cache/mock_code/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Defines fixtures for mocking AiiDA codes, with caching at the level of the executable. @@ -7,7 +6,7 @@ from ._hasher import InputHasher from ._fixtures import * -# Note: This is necessary for the sphinx doc - otherwise it does not find aiida_testing.mock_code.mock_code_factory +# Note: This is necessary for the sphinx doc - otherwise it does not find aiida_test_cache.mock_code.mock_code_factory __all__ = ( "pytest_addoption", "testing_config_action", diff --git a/aiida_testing/mock_code/_cli.py b/aiida_test_cache/mock_code/_cli.py similarity index 100% rename from aiida_testing/mock_code/_cli.py rename to aiida_test_cache/mock_code/_cli.py diff --git a/aiida_testing/mock_code/_env_keys.py b/aiida_test_cache/mock_code/_env_keys.py similarity index 100% rename from aiida_testing/mock_code/_env_keys.py rename to aiida_test_cache/mock_code/_env_keys.py diff --git a/aiida_testing/mock_code/_fixtures.py b/aiida_test_cache/mock_code/_fixtures.py similarity index 99% rename from aiida_testing/mock_code/_fixtures.py rename to aiida_test_cache/mock_code/_fixtures.py index 8e5fe4e..f19f512 100644 --- a/aiida_testing/mock_code/_fixtures.py +++ b/aiida_test_cache/mock_code/_fixtures.py @@ -214,7 +214,7 @@ def _get_mock_code( if not mock_executable_path: raise ValueError( "'aiida-mock-code' executable not found in the PATH. " + - "Have you run `pip install aiida-testing` in this python environment?" + "Have you run `pip install aiida-test-cache` in this python environment?" ) # try determine path to actual code executable diff --git a/aiida_testing/mock_code/_hasher.py b/aiida_test_cache/mock_code/_hasher.py similarity index 97% rename from aiida_testing/mock_code/_hasher.py rename to aiida_test_cache/mock_code/_hasher.py index b20e528..ada74be 100644 --- a/aiida_testing/mock_code/_hasher.py +++ b/aiida_test_cache/mock_code/_hasher.py @@ -59,7 +59,7 @@ def _strip_submit_content(content: bytes) -> bytes: """ aiidasubmit_content = content.decode() lines: ty.Iterable[str] = aiidasubmit_content.splitlines() - # Strip lines containing the aiida_testing.mock_code environment variables. + # Strip lines containing the aiida_test_cache.mock_code environment variables. lines = (line for line in lines if 'export AIIDA_MOCK' not in line) # Remove abspath of the aiida-mock-code, but keep cmdline arguments. lines = (line.split("aiida-mock-code'")[-1] for line in lines) diff --git a/aiida_testing/py.typed b/aiida_test_cache/py.typed similarity index 100% rename from aiida_testing/py.typed rename to aiida_test_cache/py.typed diff --git a/docs/source/conf.py b/docs/source/conf.py index c00572c..118fad9 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,4 +1,4 @@ -# Sphinx configuration for aiida-testing +# Sphinx configuration for aiida-test-cache # # This file is execfile()d with the current directory set to its # containing dir. @@ -14,7 +14,7 @@ import time import contextlib -import aiida_testing +import aiida_test_cache # -- AiiDA-related setup -------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, @@ -62,7 +62,7 @@ master_doc = 'index' # General information about the project. -project = 'aiida-testing' +project = 'aiida-test-cache' copyright_first_year = "2019" copyright_owners = "The AiiDA Team" @@ -76,7 +76,7 @@ # built documents. # # The full version, including alpha/beta/rc tags. -release = aiida_testing.__version__ +release = aiida_test_cache.__version__ # The short X.Y version. version = '.'.join(release.split('.')[:2]) @@ -199,7 +199,7 @@ # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -html_use_opensearch = 'http://aiida-testing.readthedocs.io' +html_use_opensearch = 'http://aiida-test-cache.readthedocs.io' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None @@ -216,7 +216,7 @@ #html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. -htmlhelp_basename = 'aiida-testing-doc' +htmlhelp_basename = 'aiida-test-cache-doc' # -- Options for LaTeX output --------------------------------------------- @@ -271,7 +271,7 @@ def run_apidoc(_): """ source_dir = os.path.abspath(os.path.dirname(__file__)) apidoc_dir = os.path.join(source_dir, 'apidoc') - package_dir = os.path.join(source_dir, os.pardir, os.pardir, 'aiida_testing') + package_dir = os.path.join(source_dir, os.pardir, os.pardir, 'aiida_test_cache') import subprocess cmd_path = 'sphinx-apidoc' @@ -388,5 +388,5 @@ def setup(app): ('py:obj', 'float'), ('py:obj', 'bool'), ('py:obj', 'Mapping'), - ('py:class', 'aiida_testing._config.Config'), + ('py:class', 'aiida_test_cache._config.Config'), ] diff --git a/docs/source/developer_guide/index.rst b/docs/source/developer_guide/index.rst index c7314a4..64f73c0 100644 --- a/docs/source/developer_guide/index.rst +++ b/docs/source/developer_guide/index.rst @@ -6,11 +6,11 @@ Full setup ++++++++++ The following commands give you a complete development setup for -``aiida-testing``. +``aiida-test-cache``. Make sure to run this in the appropriate virtual environment:: - git clone https://github.com/aiidateam/aiida-testing.git - cd aiida-testing + git clone https://github.com/aiidateam/aiida-test-cache.git + cd aiida-test-cache pip install -e .[dev] pre-commit install @@ -22,7 +22,7 @@ Running the tests The following will discover and run all unit tests:: - pip install -e .[testing] + pip install -e .[tests] pytest Automatic coding style checks @@ -46,7 +46,7 @@ If you ever need to skip these pre-commit hooks, just use:: Continuous integration ++++++++++++++++++++++ -``aiida-testing`` comes with a ``ci.yml`` file for continuous integration tests on every commit using GitHub Actions. It will: +``aiida-test-cache`` comes with a ``ci.yml`` file for continuous integration tests on every commit using GitHub Actions. It will: #. run all tests #. build the documentation @@ -55,9 +55,9 @@ Continuous integration Online documentation ++++++++++++++++++++ -The documentation of ``aiida-testing`` is continuously being built on +The documentation of ``aiida-test-cache`` is continuously being built on `ReadTheDocs `_, and the result is shown on -https://aiida-testing.readthedocs.org/. +https://aiida-test-cache.readthedocs.org/. If you have a ReadTheDocs account, you can also enable it on your own fork for testing, but you will have to use a different name. diff --git a/docs/source/index.rst b/docs/source/index.rst index 93a0793..7c259ca 100755 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -2,7 +2,7 @@ :width: 250px :align: center -The aiida-testing pytest plugin +The aiida-test-cache pytest plugin =============================== A pytest plugin to simplify testing of `AiiDA`_ plugins. It implements @@ -15,7 +15,7 @@ fixtures to cache the execution of codes: an automatic archive creation/loading. Use this to test high-level workflows. -``aiida-testing`` is available at http://github.com/aiidateam/aiida-testing +``aiida-test-cache`` is available at http://github.com/aiidateam/aiida-test-cache .. toctree:: @@ -23,7 +23,7 @@ fixtures to cache the execution of codes: user_guide/index developer_guide/index - API documentation + API documentation If you use `AiiDA`_ for your research, please cite the following work: @@ -32,7 +32,7 @@ If you use `AiiDA`_ for your research, please cite the following work: for computational science*, Comp. Mat. Sci 111, 218-230 (2016); https://doi.org/10.1016/j.commatsci.2015.09.013; http://www.aiida.net. -``aiida-testing`` is released under the Apache license. +``aiida-test-cache`` is released under the MIT license. diff --git a/docs/source/user_guide/archive_cache.rst b/docs/source/user_guide/archive_cache.rst index 23c779f..a2fe52d 100644 --- a/docs/source/user_guide/archive_cache.rst +++ b/docs/source/user_guide/archive_cache.rst @@ -2,9 +2,9 @@ Using :mod:`.archive_cache` =========================== -:mod:`.archive_cache` provides the :py:func:`~aiida_testing.archive_cache.enable_archive_cache` pytest fixture. It uses the AiiDA caching mechanisms to enable end-to-end tests of high-level workchains without executing individual `Calcjob` processes, if they can be cached from a stored archive. +:mod:`.archive_cache` provides the :py:func:`~aiida_test_cache.archive_cache.enable_archive_cache` pytest fixture. It uses the AiiDA caching mechanisms to enable end-to-end tests of high-level workchains without executing individual `Calcjob` processes, if they can be cached from a stored archive. -Here an example of using the :py:func:`~aiida_testing.archive_cache.enable_archive_cache` fixture to test a simple workchain using the ``diff`` code +Here an example of using the :py:func:`~aiida_test_cache.archive_cache.enable_archive_cache` fixture to test a simple workchain using the ``diff`` code The workchain looks as follows @@ -90,14 +90,14 @@ be ignored when computing the hash of this calcjob. .. note:: The file location of the archives used for these regression tests can be specified as the first argument to the - :py:func:`~aiida_testing.archive_cache.enable_archive_cache` and can either be an absolute or relative file path + :py:func:`~aiida_test_cache.archive_cache.enable_archive_cache` and can either be an absolute or relative file path for an AiiDA archive file If the path is absolute it will be used directly. A relative path is interpreted with respect to either the ``default_data_dir`` option in the config file, or if this option isn't specified a folder named ``caches`` in the same directory as the test file in question - So in the default case providing just the name of the archive to :py:func:`~aiida_testing.archive_cache.enable_archive_cache` + So in the default case providing just the name of the archive to :py:func:`~aiida_test_cache.archive_cache.enable_archive_cache` will create an archive with the given name in the ``caches`` subfolder diff --git a/docs/source/user_guide/get_started.rst b/docs/source/user_guide/get_started.rst index bfbff2d..02b223e 100644 --- a/docs/source/user_guide/get_started.rst +++ b/docs/source/user_guide/get_started.rst @@ -2,15 +2,12 @@ Getting started =============== -This page should contain a short guide on what the plugin does and -a short example on how to use the plugin. - Installation ++++++++++++ -Use the following commands to install ``aiida-testing``:: +Use the following commands to install ``aiida-testcache``:: - pip install aiida-testing + pip install aiida-test-cache Usage diff --git a/docs/source/user_guide/mock_code.rst b/docs/source/user_guide/mock_code.rst index 2ad6c72..fa7aedc 100644 --- a/docs/source/user_guide/mock_code.rst +++ b/docs/source/user_guide/mock_code.rst @@ -6,7 +6,7 @@ Using :mod:`.mock_code` 1. A command-line script ``aiida-mock-code`` (the *mock executable*) that is executed instead of the *actual* executable and acts as a *cache* for the outputs of the actual executable - 2. A pytest fixture :py:func:`~aiida_testing.mock_code.mock_code_factory` that sets up an AiiDA Code pointing to the mock executable + 2. A pytest fixture :py:func:`~aiida_test_cache.mock_code.mock_code_factory` that sets up an AiiDA Code pointing to the mock executable In the following, we will set up a mock code for the ``diff`` executable in three simple steps. @@ -32,7 +32,7 @@ First, we want to define a fixture for our mocked code in the ``conftest.py``: # files *not* to copy into the data directory ignore_files=('_aiidasubmit.sh', 'file*') ) - + Second, we need to tell the mock executable where to find the *actual* ``diff`` executable by creating a ``.aiida-testing-config.yml`` file in the top level of our plugin. .. note:: diff --git a/pyproject.toml b/pyproject.toml index dc1dd04..374a58e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,10 +3,10 @@ requires = ["flit_core >=3.4,<4"] build-backend = "flit_core.buildapi" [tool.flit.module] -name = "aiida_testing" +name = "aiida_test_cache" [project] -name = "aiida-testing" +name = "aiida-test-cache" dynamic = ["version", "description"] authors = [ {name = "Dominik Gresch"}, @@ -39,7 +39,7 @@ keywords = [ "mock", "cache", ] -urls = {Homepage = "https://aiida-testing.readthedocs.io/"} +urls = {Homepage = "https://aiida-test-cache.readthedocs.io/"} requires-python = ">=3.7" # Note the dependency on setuptools due to pkg_resources dependencies = [ @@ -51,7 +51,7 @@ dependencies = [ [project.optional-dependencies] docs = ["sphinx", "sphinx-rtd-theme"] -testing = [ +tests = [ "pgtest~=1.3.1", "aiida-diff", "pytest-datadir", @@ -65,15 +65,15 @@ pre_commit = [ "types-PyYAML", ] dev = [ - 'aiida-testing[testing,pre_commit,docs]', + 'aiida-test-cache[tests,pre_commit,docs]', ] [project.scripts] -aiida-mock-code = "aiida_testing.mock_code._cli:run" +aiida-mock-code = "aiida_test_cache.mock_code._cli:run" [project.entry-points."pytest11"] -aiida_mock_code = "aiida_testing.mock_code" -aiida_archive_cache = "aiida_testing.archive_cache" +aiida_mock_code = "aiida_test_cache.mock_code" +aiida_archive_cache = "aiida_test_cache.archive_cache" [tool.pylint.format] max-line-length = 120 @@ -122,7 +122,7 @@ envlist = py38 usedevelop = true [testenv:py{37,38,39,310,311}] -extras = testing +extras = tests commands = pytest {posargs} [testenv:pre-commit-py{38,39,310,311}] diff --git a/tests/archive_cache/test_archive_cache.py b/tests/archive_cache/test_archive_cache.py index dc0da31..45239ea 100644 --- a/tests/archive_cache/test_archive_cache.py +++ b/tests/archive_cache/test_archive_cache.py @@ -15,7 +15,7 @@ from aiida.orm.querybuilder import QueryBuilder from aiida.plugins import CalculationFactory -from aiida_testing.archive_cache._utils import create_node_archive, load_node_archive +from aiida_test_cache.archive_cache._utils import create_node_archive, load_node_archive CALC_ENTRY_POINT = 'diff' diff --git a/tests/conftest.py b/tests/conftest.py index a7d8c23..31d1bcf 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,5 @@ -# -*- coding: utf-8 -*- """ -Configuration file for pytest tests of aiida-testing. +Configuration file for pytest tests of aiida-test-cache. """ import pytest diff --git a/tests/mock_code/test_ignore_paths.py b/tests/mock_code/test_ignore_paths.py index f96e4da..eac4f14 100644 --- a/tests/mock_code/test_ignore_paths.py +++ b/tests/mock_code/test_ignore_paths.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Test that ignoring paths works as expected. """ @@ -6,7 +5,7 @@ from pathlib import Path import pytest -from aiida_testing.mock_code._cli import copy_files +from aiida_test_cache.mock_code._cli import copy_files OUTPUT_PATHS = ( Path('file1.txt'), diff --git a/tests/mock_code/test_isolated.py b/tests/mock_code/test_isolated.py index 39cff0f..925eb36 100644 --- a/tests/mock_code/test_isolated.py +++ b/tests/mock_code/test_isolated.py @@ -71,7 +71,7 @@ def test_custom_hasher(pytester: pytest.Pytester): pytester.makepyfile( """ from aiida.engine import run_get_node - from aiida_testing.mock_code import InputHasher + from aiida_test_cache.mock_code import InputHasher class CustomHasher(InputHasher): def modify_content(self, path, content): if path.name == 'file1.txt':