Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename package: aiida-testing -> aiida-test-cache #76

Merged
merged 7 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
23 changes: 12 additions & 11 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# .readthedocs.yml
---
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
Expand All @@ -11,12 +10,14 @@ sphinx:

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- method: pip
path: .
extra_requirements:
- docs
build:
os: ubuntu-22.04
tools:
python: '3.11'
commands:
- asdf plugin add uv
- asdf install uv 0.5.2
- asdf global uv 0.5.2
- uv venv
- uv pip install .[docs]
- . .venv/bin/activate && cd docs && make BUILDDIR=$READTHEDOCS_OUTPUT
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
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.
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 = [
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I was here, I made it in line with other AiiDA repos that use tests extras.

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
Loading