Skip to content

Commit

Permalink
Rename package: aiida-testing->aiida-test-cache
Browse files Browse the repository at this point in the history
The only remaining thing is the name of the default
config file, will be dealt with separately.
  • Loading branch information
danielhollas committed Nov 18, 2024
1 parent fdd0de1 commit 3586d7c
Show file tree
Hide file tree
Showing 24 changed files with 52 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
version: ${{ env.UV_VER }}
- name: Install package
run: |
uv pip install --system -e .[testing]
uv pip install --system -e .[tests]
reentry scan -r aiida || true
- name: Run test suite
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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/).
File renamed without changes.
2 changes: 1 addition & 1 deletion aiida_testing/_config.py → aiida_test_cache/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Defines fixtures for mocking AiiDA codes, with caching at the level of
the executable.
Expand All @@ -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",
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
File renamed without changes.
16 changes: 8 additions & 8 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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,
Expand Down Expand Up @@ -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"

Expand All @@ -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])

Expand Down Expand Up @@ -199,7 +199,7 @@
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> 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
Expand All @@ -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 ---------------------------------------------

Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'),
]
14 changes: 7 additions & 7 deletions docs/source/developer_guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 <https://readthedocs.org/>`_, 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.
Expand Down
10 changes: 5 additions & 5 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
: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
fixtures to cache the execution of codes:
Expand All @@ -15,15 +15,15 @@ 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::
:maxdepth: 2

user_guide/index
developer_guide/index
API documentation <apidoc/aiida_testing>
API documentation <apidoc/aiida_test_cache>

If you use `AiiDA`_ for your research, please cite the following work:

Expand All @@ -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.



Expand Down
8 changes: 4 additions & 4 deletions docs/source/user_guide/archive_cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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


Expand Down
7 changes: 2 additions & 5 deletions docs/source/user_guide/get_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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-test-cache``::

pip install aiida-testing
pip install aiida-test-cache


Usage
Expand Down
4 changes: 2 additions & 2 deletions docs/source/user_guide/mock_code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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::
Expand Down
18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down Expand Up @@ -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 = [
Expand All @@ -51,7 +51,7 @@ dependencies = [

[project.optional-dependencies]
docs = ["sphinx", "sphinx-rtd-theme"]
testing = [
tests = [
"pgtest~=1.3.1",
"aiida-diff",
"pytest-datadir",
Expand All @@ -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
Expand Down Expand Up @@ -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}]
Expand Down
2 changes: 1 addition & 1 deletion tests/archive_cache/test_archive_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 1 addition & 2 deletions tests/mock_code/test_ignore_paths.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
"""
Test that ignoring paths works as expected.
"""
import os
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'),
Expand Down
2 changes: 1 addition & 1 deletion tests/mock_code/test_isolated.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down

0 comments on commit 3586d7c

Please sign in to comment.