Packaging/dev-tools/docs update #244

Merged
cmo merged 19 commits from packaging into master 2026-07-01 09:00:58 +00:00
70 changed files with 1518 additions and 1327 deletions

View file

@ -2,7 +2,7 @@
---
name: Codespell
on: workflow_dispatch
on: [push, pull_request, workflow_dispatch]
permissions:
contents: read
@ -10,13 +10,13 @@ permissions:
jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest
runs-on: debian-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Codespell
uses: codespell-project/actions-codespell@v2
uses: https://github.com/codespell-project/actions-codespell@v2
with:
ignore_words_list: crate

View file

@ -0,0 +1,36 @@
name: Type annotation (PR)
on:
pull_request:
paths:
- 'dump_things_service/**.py'
- '!**/tests/**.py'
jobs:
check:
runs-on: debian-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install hatch
run: uv tool install hatch
- name: Get Python changed files
id: changed-py-files
uses: https://github.com/tj-actions/changed-files@v46
with:
files: |
*.py
**/*.py
- name: Type check changed files
if: steps.changed-py-files.outputs.any_changed == 'true'
run: |
# get any type stubs that mypy thinks it needs
# run mypy on the modified files only, and do not even follow imports.
# this results is a fairly superficial test, but given the overall
# state of annotations, we strive to become more correct incrementally
# with focused error reports, rather than barfing a huge complaint
# that is unrelated to the changeset someone has been working on.
# run on the oldest supported Python version
hatch run types:mypy --install-types --non-interactive --python-version 3.11 --follow-imports skip --pretty --show-error-context ${{ steps.changed-py-files.outputs.all_changed_files }}

View file

@ -0,0 +1,17 @@
name: Ruff
on: [push, pull_request]
jobs:
ruff:
name: Code linting
runs-on: debian-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install hatch
run: uv tool install hatch
- name: Check code
run: hatch check code
- name: Check formatting
run: hatch check fmt

View file

@ -12,9 +12,6 @@ jobs:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v6
@ -23,14 +20,14 @@ jobs:
- name: Run tests
run: |
hatch run tests:run \
hatch test \
--ignore=dump_things_service/tests/test_generators.py \
--ignore=dump_things_service/tests/test_ifabsent_patch.py
- name: Run generator tests
run: |
hatch run tests:run dump_things_service/tests/test_generators.py
hatch test dump_things_service/tests/test_generators.py
- name: Run ifabsent-patch tests
run: |
hatch run tests:run dump_things_service/tests/test_ifabsent_patch.py
hatch test dump_things_service/tests/test_ifabsent_patch.py

2
.gitignore vendored
View file

@ -3,3 +3,5 @@ dist/**
tmp/**
**/__pycache__
**/.hypothesis
.*.swp
dump_things_service/_version.py

31
.readthedocs.yaml Normal file
View file

@ -0,0 +1,31 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Set the OS, Python version and other tools you might need
build:
os: ubuntu-24.04
tools:
python: "3.12"
# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py
# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub
# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- method: pip
path: .
extra_requirements:
- docs

View file

@ -123,7 +123,7 @@
3. The top-level mapping `admin_tokens` was added.
- Configuration files are no longer read when the service is started. Instead
the service reads its configuration from the store, if it is present. Thw tool
the service reads its configuration from the store, if it is present. The tool
(`dump-things-load-config`) can read an existing configuration
file and manifest the described configuration on a running dump-things server.
It supports pre version 6 config files and converts them to the new

View file

@ -594,7 +594,7 @@ Most endpoints require a *collection*. These correspond to the names of the "dat
The service provides the following user endpoints (In addition to user endpoints, there exist endpoints for curators. To view them, check the `/docs`-path in an installed service):
- `POST /maintenance`: this endpoint allows to set a collection into mantenance mode.
- `POST /maintenance`: this endpoint allows to set a collection into maintenance mode.
In maintenance mode, only tokens with curator-privileges can access the collection.
The posted data is a JSON that contains the name of the collection and whether the maintenance state should be active or not, for example:
```json

2
docs/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
_build
generated

20
docs/Makefile Normal file
View file

@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?= --fail-on-warning
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

0
docs/_static/.gitkeep vendored Normal file
View file

48
docs/conf.py Normal file
View file

@ -0,0 +1,48 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
import dump_things_service
project = 'dump-things-server'
copyright = '2025-2026, Christian Mönch'
author = 'Christian Mönch'
release = dump_things_service.__version__
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
'sphinx.ext.autosummary',
'sphinx.ext.autodoc',
'sphinx_autodoc_typehints',
'sphinx.ext.viewcode',
]
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
primary_domain = 'py'
autoclass_content = "both"
typehints_use_signature = True
typehints_use_signature_return = True
# we build some docstrings from loguru. define some no-op substitutions
# to avoid errors
rst_prolog = """
.. |Logger| replace:: Logger
.. |add| replace:: add
.. |sys.stderr| replace:: sys.stderr
.. |str.format| replace:: str.format
"""
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']

10
docs/index.rst Normal file
View file

@ -0,0 +1,10 @@
The `dump-thing-server` documentation
=====================================
HERE BE CONTENT...
Indices and tables
==================
* :ref:`genindex`
* :ref:`search`

View file

@ -20,8 +20,9 @@ from starlette.status import (
HTTP_503_SERVICE_UNAVAILABLE,
)
from dump_things_service._version import __version__
__all__ = [
'Format',
'HTTP_200_OK',
'HTTP_201_CREATED',
'HTTP_300_MULTIPLE_CHOICES',
@ -37,6 +38,8 @@ __all__ = [
'HTTP_503_SERVICE_UNAVAILABLE',
'JSON',
'YAML',
'Format',
'__version__',
'config_file_name',
'reserved_collection_names',
]

View file

@ -1,14 +1,13 @@
import enum
import hashlib
import logging
from collections.abc import Callable, Iterable
from functools import partial
from pathlib import (
Path,
PurePosixPath,
)
from typing import (
Callable,
Iterable,
Literal,
cast,
)
@ -17,7 +16,8 @@ from fastapi import HTTPException
from pydantic import (
BaseModel,
ConfigDict,
Field, ValidationError,
Field,
ValidationError,
)
from yaml.scanner import ScannerError
@ -27,12 +27,11 @@ from dump_things_service import (
)
from dump_things_service.audit.gitaudit import GitAuditBackend
from dump_things_service.backends.record_dir import (
_RecordDirStore,
RecordDirStore,
_RecordDirStore,
)
from dump_things_service.exceptions import ConfigError
logger = logging.getLogger('dump_things_service')
g_abstract_configuration = None
@ -103,7 +102,9 @@ class CollectionConfig(BaseModel):
curated: PurePosixPath
schema_location: str = Field(alias='schema')
incoming: PurePosixPath | None = None
backend: RecordDirBackendConfig | SQLiteBackendConfig = RecordDirBackendConfig(type='record_dir+stl')
backend: RecordDirBackendConfig | SQLiteBackendConfig = RecordDirBackendConfig(
type='record_dir+stl'
)
auth_sources: list[ForgejoAuthSpec | ConfigAuthSpec] = [ConfigAuthSpec()]
audit_backends: list[GitAuditBackendConfig] = []
submission_tags: TagSpec = TagSpec()
@ -200,7 +201,7 @@ def get_token_permissions(mode: str) -> TokenPermission:
def get_config_backends(
store_path: Path,
store_path: Path,
) -> tuple[_RecordDirStore, GitAuditBackend]:
global config_audit
global config_backend
@ -211,9 +212,7 @@ def get_config_backends(
if config_backend is None:
config_backend = RecordDirStore(
config_path,
mapping_functions[MappingMethod.digest_md5],
'yaml'
config_path, mapping_functions[MappingMethod.digest_md5], 'yaml'
)
audit_path = store_path / config_audit_path
@ -226,8 +225,8 @@ def get_config_backends(
def read_config(
store_path: Path,
force_reload: bool = False,
store_path: Path,
force_reload: bool = False,
) -> Configuration:
global g_abstract_configuration
@ -244,7 +243,7 @@ def read_config(
if record_info
else Configuration(
type='collections',
version = 2,
version=2,
)
)
except ValidationError as ve:
@ -259,12 +258,12 @@ def get_config() -> Configuration:
if not g_abstract_configuration:
msg = 'Configuration not yet loaded'
raise RuntimeError(msg)
return cast(Configuration, g_abstract_configuration)
return cast('Configuration', g_abstract_configuration)
def store_config(
store_path,
config: Configuration,
store_path,
config: Configuration,
):
global g_abstract_configuration
@ -274,7 +273,7 @@ def store_config(
config_backend.add_record(
iri=dump_things_config_iri,
class_name='DumpThingsConfig',
json_object=json_object
json_object=json_object,
)
audit_backend.add_record(
record=json_object,
@ -284,8 +283,8 @@ def store_config(
def tokens_for_collection(
config: Configuration,
collection: str,
config: Configuration,
collection: str,
) -> Iterable[TokenConfig]:
yield from (
token
@ -295,8 +294,8 @@ def tokens_for_collection(
def check_collection(
abstract_config: Configuration,
collection: str,
abstract_config: Configuration,
collection: str,
):
if collection not in abstract_config.collections:
raise HTTPException(
@ -306,18 +305,17 @@ def check_collection(
def check_label(
store_path: Path,
abstract_config: Configuration,
collection: str,
label: str,
store_path: Path,
abstract_config: Configuration,
collection: str,
label: str,
):
from dump_things_service.utils import get_on_disk_labels
"""Check that a label exists in a collection configuration or on disk"""
if (
label not in get_config_labels(abstract_config, collection)
and label not in get_on_disk_labels(store_path, abstract_config, collection)
):
if label not in get_config_labels(
abstract_config, collection
) and label not in get_on_disk_labels(store_path, abstract_config, collection):
raise HTTPException(
status_code=HTTP_404_NOT_FOUND,
detail=f"No incoming label: '{label}' in collection: '{collection}'.",
@ -325,8 +323,8 @@ def check_label(
def get_config_labels(
abstract_config: Configuration,
collection: str,
abstract_config: Configuration,
collection: str,
) -> set[str]:
check_collection(abstract_config, collection)
return {
@ -336,17 +334,14 @@ def get_config_labels(
}
def get_default_token_name(
abstract_config: Configuration,
collection: str
) -> str:
def get_default_token_name(abstract_config: Configuration, collection: str) -> str:
check_collection(abstract_config, collection)
return abstract_config.collections[collection].default_token
def get_token_info_by_representation(
abstract_config: Configuration,
token_representation: str,
abstract_config: Configuration,
token_representation: str,
) -> tuple[str, TokenConfig] | None:
"""Get the name of the token given in `token_representation`"""
hashed_representation = hash_token_representation(token_representation)
@ -361,23 +356,22 @@ def get_token_info_by_representation(
def hash_token_representation(
token_representation: str,
token_representation: str,
) -> str:
return hashlib.sha256(token_representation.encode()).hexdigest()
def get_token_config_by_name(
abstract_config: Configuration,
token_name: str,
abstract_config: Configuration,
token_name: str,
) -> TokenConfig | None:
return abstract_config.tokens.get(token_name)
def get_token_infos_for_collection(
abstract_config: Configuration,
collection_name: str,
abstract_config: Configuration,
collection_name: str,
) -> Iterable[tuple[str, TokenConfig, TokenCollectionConfig]]:
yield from {
(token_name, token_config, token_collection_config)
for token_name, token_config in abstract_config.tokens.items()
@ -387,11 +381,10 @@ def get_token_infos_for_collection(
def get_token_config_for_representation_and_collection(
abstract_config: Configuration,
collection_name: str,
token_representation: str,
abstract_config: Configuration,
collection_name: str,
token_representation: str,
) -> tuple[str, TokenConfig, TokenCollectionConfig] | None:
token_info = get_token_info_by_representation(
abstract_config=abstract_config,
token_representation=token_representation,
@ -405,8 +398,8 @@ def get_token_config_for_representation_and_collection(
def get_collection_config_by_name(
abstract_config: Configuration,
collection_name: str,
abstract_config: Configuration,
collection_name: str,
) -> CollectionConfig:
collection_config = abstract_config.collections.get(collection_name)
if not collection_config:
@ -418,10 +411,9 @@ def get_collection_config_by_name(
def get_default_token_config(
abstract_config: Configuration,
collection: str,
abstract_config: Configuration,
collection: str,
) -> TokenConfig | None:
default_token_name = get_collection_config_by_name(
abstract_config,
collection,
@ -445,18 +437,18 @@ def get_hex_digest(hasher: Callable, data: str) -> str:
def mapping_digest_p3(
hasher: Callable,
pid: str,
suffix: str,
hasher: Callable,
pid: str,
suffix: str,
) -> Path:
hex_digest = get_hex_digest(hasher, pid)
return Path(hex_digest[:3]) / (hex_digest[3:] + '.' + suffix)
def mapping_digest_p3_p3(
hasher: Callable,
pid: str,
suffix: str,
hasher: Callable,
pid: str,
suffix: str,
) -> Path:
hex_digest = get_hex_digest(hasher, pid)
return Path(hex_digest[:3]) / hex_digest[3:6] / (hex_digest[6:] + '.' + suffix)

View file

@ -9,14 +9,13 @@ from dump_things_service.abstract_config import (
)
from dump_things_service.instance_state import InstanceState
logger = logging.getLogger('dump_things_service')
def authenticate_admin(
instance_state: InstanceState,
abstract_config: Configuration,
api_key: str,
instance_state: InstanceState,
abstract_config: Configuration,
api_key: str,
):
if api_key:
hashed_token_representation = hash_token_representation(api_key)

View file

@ -7,10 +7,10 @@ from abc import (
class AuditBackend(metaclass=ABCMeta):
@abstractmethod
def add_record(
self,
record: dict,
committer_id: str,
author_id: str | None = None,
self,
record: dict,
committer_id: str,
author_id: str | None = None,
) -> None:
"""Add information about a new record version to the audit log
@ -35,8 +35,8 @@ class AuditBackend(metaclass=ABCMeta):
@abstractmethod
def get_audit_log(
self,
record_id: str,
self,
record_id: str,
) -> dict:
"""Get the content of the audit log

View file

@ -6,6 +6,7 @@ committed.
Changes are annotated with a time stamp and a user-id
"""
from __future__ import annotations
import hashlib
@ -23,21 +24,20 @@ import yaml
from datalad_core.git_utils import apply_changeset
from datalad_core.repo import Repo
from datalad_core.runners import (
call_git,
CommandError,
call_git,
)
from . import AuditBackend
from dump_things_service.audit import AuditBackend
index_file_name = 'gitaudit_index.log'
class FlushingThread(Thread):
def __init__(
self,
backend: GitAuditBackend,
auto_flush_timeout: int,
self,
backend: GitAuditBackend,
auto_flush_timeout: int,
):
super().__init__()
self.auto_flush_timeout = auto_flush_timeout
@ -56,11 +56,10 @@ class FlushingThread(Thread):
class GitAuditBackend(AuditBackend):
def __init__(
self,
path: Path,
auto_flush_timeout: int = 60,
self,
path: Path,
auto_flush_timeout: int = 60,
):
self.path = path
self.index_path = None
@ -69,7 +68,8 @@ class GitAuditBackend(AuditBackend):
self.lock = Lock()
self.last_flush_time = 0
if auto_flush_timeout < 1:
raise ValueError('auto_flush_timeout must be greater or equal to 1')
msg = 'auto_flush_timeout must be greater or equal to 1'
raise ValueError(msg)
self.flushing_thread = FlushingThread(self, auto_flush_timeout)
self.flushing_thread.start()
self._init_repo()
@ -82,10 +82,10 @@ class GitAuditBackend(AuditBackend):
self.flushing_thread = None
def add_record(
self,
record: dict,
committer_id: str,
author_id: str | None = None,
self,
record: dict,
committer_id: str,
author_id: str | None = None,
) -> None:
with self.lock:
author_id = committer_id if author_id is None else author_id
@ -109,15 +109,15 @@ class GitAuditBackend(AuditBackend):
self.last_flush_time = time.time()
def get_audit_log(
self,
record_id: str,
self,
record_id: str,
) -> dict:
with self.lock:
return self._locked_get_audit_log(record_id)
def _locked_get_audit_log(
self,
record_id: str,
self,
record_id: str,
) -> dict:
self._locked_flush()
@ -125,32 +125,42 @@ class GitAuditBackend(AuditBackend):
# the records
changes = []
yaml_location, log_location = map(str, self._get_location_for(record_id)[1:])
commit_hashes = call_git(
['log', '--format=%H', '--', log_location],
cwd=self.path,
capture_output=True,
).decode().splitlines()
for commit_hash in commit_hashes:
log_diff_lines = call_git(
['show', '--format=%b', commit_hash, '--', log_location],
commit_hashes = (
call_git(
['log', '--format=%H', '--', log_location],
cwd=self.path,
capture_output=True,
).decode().splitlines()
)
.decode()
.splitlines()
)
for commit_hash in commit_hashes:
log_diff_lines = (
call_git(
['show', '--format=%b', commit_hash, '--', log_location],
cwd=self.path,
capture_output=True,
)
.decode()
.splitlines()
)
# Get the log entry
log_line = tuple(
filter(
log_line = next(filter(
lambda l: not l.startswith('+++') and l.startswith('+'),
log_diff_lines,
)
)[0][1:]
))[1:]
log_entry = json.loads(log_line)
# Get the YAML diff
yaml_diff_lines = call_git(
['show', '--format=%b', commit_hash, '--', yaml_location],
cwd=self.path,
capture_output=True,
).decode().splitlines()
yaml_diff_lines = (
call_git(
['show', '--format=%b', commit_hash, '--', yaml_location],
cwd=self.path,
capture_output=True,
)
.decode()
.splitlines()
)
yaml_diff = '\n'.join(filter(lambda l: l != '', yaml_diff_lines)) + '\n'
# Get the YAML content
@ -173,15 +183,15 @@ class GitAuditBackend(AuditBackend):
return {c[0]: c[1:] for c in changes}
def get_audit_logs(
self,
record_id_pattern: str,
self,
record_id_pattern: str,
) -> dict:
with self.lock:
return self._locked_get_audit_logs(record_id_pattern)
def _locked_get_audit_logs(
self,
record_id_pattern: str,
self,
record_id_pattern: str,
) -> dict:
self._locked_flush()
matcher = re.compile(record_id_pattern)
@ -197,12 +207,12 @@ class GitAuditBackend(AuditBackend):
}
def _add_elements(
self,
record_id: str,
location: tuple[str, Path, Path],
committer_id: str,
author_id: str,
record: dict,
self,
record_id: str,
location: tuple[str, Path, Path],
committer_id: str,
author_id: str,
record: dict,
) -> bool:
existing_record = self._read_record_from_repo_path(location[1])
if existing_record != record:
@ -218,10 +228,10 @@ class GitAuditBackend(AuditBackend):
return False
def _add_log_entry(
self,
log_location: Path,
committer_id: str,
author_id: str,
self,
log_location: Path,
committer_id: str,
author_id: str,
) -> None:
time_stamp = datetime.now().isoformat()
entry = {
@ -234,20 +244,20 @@ class GitAuditBackend(AuditBackend):
self.current_change_set[log_location] = log_content
def _add_index_entry(
self,
record_id: str,
self,
record_id: str,
):
if record_id not in self.index:
self.cached_index_entries.append(record_id)
self.index.add(record_id)
def _read_from_repo_path(
self,
path: Path,
self,
path: Path,
) -> bytes:
try:
return call_git(
['cat-file', '-p', f'master:{str(path)}'],
['cat-file', '-p', f'master:{path!s}'],
cwd=self.path,
capture_output=True,
)
@ -257,14 +267,14 @@ class GitAuditBackend(AuditBackend):
raise
def _read_record_from_repo_path(
self,
path: Path,
self,
path: Path,
):
return yaml.safe_load(self._read_from_repo_path(path))
def _has_pending_changes(
self,
location: tuple[str, Path, Path],
self,
location: tuple[str, Path, Path],
) -> bool:
log_pending = location[1] in self.current_change_set
record_pending = location[2] in self.current_change_set
@ -286,11 +296,11 @@ class GitAuditBackend(AuditBackend):
self.current_change_set = {}
def _get_location_for(
self,
record_id: str,
self,
record_id: str,
) -> tuple[str, Path, Path]:
base = hashlib.sha1(record_id.encode()).hexdigest()
dir_1, dir_2, name = base[0:3], base[3:6], base[6:]
dir_1, dir_2, _name = base[0:3], base[3:6], base[6:]
location_dir = Path(dir_1) / Path(dir_2)
return (
base,
@ -321,28 +331,32 @@ class GitAuditBackend(AuditBackend):
if not self.index_path.exists():
self._rebuild_index()
with open(self.index_path, 'rt') as f:
self.index = set(line.strip() for line in f.readlines())
with open(self.index_path) as f:
self.index = {line.strip() for line in f}
def _add_to_index(
self,
record_id: str,
self,
record_id: str,
):
if record_id not in self.index:
self.cached_index_entries.append(record_id)
self.index.add(record_id)
def _rebuild_index(self):
tree_entries = call_git(
['ls-tree', '-r', 'master:'],
cwd=self.path,
capture_output=True,
).decode().splitlines()
with open(self.index_path, 'wt') as f:
tree_entries = (
call_git(
['ls-tree', '-r', 'master:'],
cwd=self.path,
capture_output=True,
)
.decode()
.splitlines()
)
with open(self.index_path, 'w') as f:
for line in tree_entries:
if not line.endswith('.yaml'):
continue
flag, object_type, object_hash, file_name = line.split(maxsplit=3)
_flag, _object_type, object_hash, _file_name = line.split(maxsplit=3)
record = yaml.safe_load(
call_git(
['show', object_hash],

View file

@ -19,7 +19,7 @@ def _get_audit_log_lines(backend: GitAuditBackend, record_id: str) -> list[str]:
def test_gitaudit_basic(tmp_path_factory):
tmp_path = tmp_path_factory.mktemp("gitaudit_backend")
tmp_path = tmp_path_factory.mktemp('gitaudit_backend')
backend = GitAuditBackend(tmp_path)
@ -44,14 +44,13 @@ def test_gitaudit_basic(tmp_path_factory):
# Check that the changes are reported
changes = backend.get_audit_log(record_id)
assert len(changes) == 4
assert tuple(map(lambda e: e[0:2], changes.values())) == tuple(
(f'committer_{100 + i}@x.org', f'author_{i}@y.org')
for i in range(4)
assert tuple(e[0:2] for e in changes.values()) == tuple(
(f'committer_{100 + i}@x.org', f'author_{i}@y.org') for i in range(4)
)
def test_gitaudit_identical_change(tmp_path_factory):
tmp_path = tmp_path_factory.mktemp("gitaudit_backend")
tmp_path = tmp_path_factory.mktemp('gitaudit_backend')
backend = GitAuditBackend(tmp_path)
@ -59,13 +58,13 @@ def test_gitaudit_identical_change(tmp_path_factory):
backend.add_record(
record={'pid': record_id},
committer_id='committer_b@x.org',
author_id = 'author_b@y.org',
author_id='author_b@y.org',
)
backend.add_record(
record={'pid': record_id},
committer_id='committer_b@x.org',
author_id = 'author_b@y.org',
author_id='author_b@y.org',
)
# Check that there is only one entry in the audit log
@ -83,7 +82,7 @@ def test_gitaudit_identical_change(tmp_path_factory):
def test_gitaudit_huge_log(tmp_path_factory):
tmp_path = tmp_path_factory.mktemp("gitaudit_backend")
tmp_path = tmp_path_factory.mktemp('gitaudit_backend')
backend = GitAuditBackend(tmp_path)
@ -96,7 +95,7 @@ def test_gitaudit_huge_log(tmp_path_factory):
backend.add_record(
record={'pid': record_id, 'content': f'j:{j}, i:{i}'},
committer_id='committer@x.org',
author_id = 'author@y.org',
author_id='author@y.org',
)
# Check that the changes are reported

View file

@ -8,6 +8,7 @@ determine:
- the incoming_label to be used with the token
"""
from __future__ import annotations
import abc

Some files were not shown because too many files have changed in this diff Show more