Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 1 addition & 12 deletions tests/orm/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
###########################################################################
"""Test for entity fields"""

import sys
from importlib.metadata import entry_points

import pytest
Expand All @@ -20,16 +19,7 @@

EPS = entry_points()

# These regression tests compare ``repr()`` output of field objects against YAML reference
# files. Since ``repr()`` of ``typing`` generics is not stable across Python versions
# (e.g. Python 3.14 renders ``typing.Dict`` as ``dict`` and ``typing.Optional[X]`` as
# ``X | None``), the reference files are only valid for the Python version they were
# generated with. Rather than maintaining two sets of reference files, we skip on
# Python versions that don't match.
skip_below_py314 = pytest.mark.skipif(sys.version_info < (3, 14), reason='typing repr fixtures require Python >=3.14.0')


@skip_below_py314
@pytest.mark.parametrize(
'entity_cls',
(orm.AuthInfo, orm.Comment, orm.Computer, orm.Group, orm.Log, orm.User),
Expand All @@ -47,11 +37,10 @@ def node_and_data_entry_points() -> list[tuple[str, str]]:
_eps: list[tuple[str, str]] = []
eps = entry_points()
for group in ['aiida.node', 'aiida.data']:
_eps.extend((group, ep.name) for ep in eps.select(group=group) if ep.name.startswith('core.'))
_eps.extend((group, ep.name) for ep in eps.select(group=group))
return _eps


@skip_below_py314
def test_all_node_fields(node_and_data_entry_points: list[tuple[str, str]], data_regression):
"""Test that all the node fields are correctly registered."""
for group, name in node_and_data_entry_points:
Expand Down
43 changes: 20 additions & 23 deletions tests/orm/test_fields/fields_aiida.node.data.Data.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
attributes:
QbDictField('attributes', dtype=typing.Optional[typing.Dict[str, typing.Any]],
is_attribute=False, is_subscriptable=True)
computer: QbNumericField('computer', dtype=typing.Optional[str], is_attribute=False)
ctime: QbNumericField('ctime', dtype=typing.Optional[datetime.datetime], is_attribute=False)
description: QbStrField('description', dtype=typing.Optional[str], is_attribute=False)
extras:
QbDictField('extras', dtype=typing.Optional[typing.Dict[str, typing.Any]],
is_attribute=False, is_subscriptable=True)
label: QbStrField('label', dtype=typing.Optional[str], is_attribute=False)
mtime: QbNumericField('mtime', dtype=typing.Optional[datetime.datetime], is_attribute=False)
node_type: QbStrField('node_type', dtype=typing.Optional[str], is_attribute=False)
pk: QbNumericField('pk', dtype=typing.Optional[int], is_attribute=False)
process_type: QbStrField('process_type', dtype=typing.Optional[str], is_attribute=False)
repository_content:
QbDictField('repository_content', dtype=typing.Optional[dict[str,
bytes]], is_attribute=False)
repository_metadata:
QbDictField('repository_metadata', dtype=typing.Optional[typing.Dict[str,
typing.Any]], is_attribute=False)
source: QbDictField('source', dtype=typing.Optional[dict], is_attribute=True, is_subscriptable=True)
user: QbNumericField('user', dtype=typing.Optional[int], is_attribute=False)
uuid: QbStrField('uuid', dtype=typing.Optional[str], is_attribute=False)
attributes: QbAttributesField('attributes', dtype=<class 'aiida.orm.nodes.data.data.Data.AttributesModel'>,
doc='The node attributes')
computer: QbNumericField('computer', dtype=int | None, doc='The PK of the computer')
ctime: QbNumericField('ctime', dtype=<class 'datetime.datetime'>, doc='The creation
time of the node')
description: QbStrField('description', dtype=<class 'str'>, doc='The node description')
extras: QbDictField('extras', dtype=dict[str, typing.Any], doc='The node extras')
label: QbStrField('label', dtype=<class 'str'>, doc='The node label')
mtime: QbNumericField('mtime', dtype=<class 'datetime.datetime'>, doc='The modification
time of the node')
node_type: QbStrField('node_type', dtype=<class 'str'>, doc='The type of the node.')
pk: QbNumericField('pk', dtype=<class 'int'>, doc='The primary key of the entity')
process_type: QbStrField('process_type', dtype=str | None, doc='The process type of
the node')
repository_metadata: QbDictField('repository_metadata', dtype=dict[str, typing.Any],
doc='Virtual hierarchy of the file repository')
source: QbDictField('attributes.source', dtype=dict | None, doc='Source of the data')
user: QbNumericField('user', dtype=<class 'int'>, doc='The PK of the user who owns
the node')
uuid: QbAnyField('uuid', dtype=<class 'uuid.UUID'>, doc='The UUID of the node')
65 changes: 35 additions & 30 deletions tests/orm/test_fields/fields_aiida.node.process.ProcessNode.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
attributes:
QbDictField('attributes', dtype=typing.Optional[typing.Dict[str, typing.Any]],
is_attribute=False, is_subscriptable=True)
computer: QbNumericField('computer', dtype=typing.Optional[str], is_attribute=False)
ctime: QbNumericField('ctime', dtype=typing.Optional[datetime.datetime], is_attribute=False)
description: QbStrField('description', dtype=typing.Optional[str], is_attribute=False)
exception: QbStrField('exception', dtype=typing.Optional[str], is_attribute=True)
exit_message: QbStrField('exit_message', dtype=typing.Optional[str], is_attribute=True)
exit_status: QbNumericField('exit_status', dtype=typing.Optional[int], is_attribute=True)
extras:
QbDictField('extras', dtype=typing.Optional[typing.Dict[str, typing.Any]],
is_attribute=False, is_subscriptable=True)
label: QbStrField('label', dtype=typing.Optional[str], is_attribute=False)
mtime: QbNumericField('mtime', dtype=typing.Optional[datetime.datetime], is_attribute=False)
node_type: QbStrField('node_type', dtype=typing.Optional[str], is_attribute=False)
paused: QbField('paused', dtype=<class 'bool'>, is_attribute=True)
pk: QbNumericField('pk', dtype=typing.Optional[int], is_attribute=False)
process_label: QbStrField('process_label', dtype=typing.Optional[str], is_attribute=True)
process_state: QbStrField('process_state', dtype=typing.Optional[str], is_attribute=True)
process_status: QbStrField('process_status', dtype=typing.Optional[str], is_attribute=True)
process_type: QbStrField('process_type', dtype=typing.Optional[str], is_attribute=False)
repository_content:
QbDictField('repository_content', dtype=typing.Optional[dict[str,
bytes]], is_attribute=False)
repository_metadata:
QbDictField('repository_metadata', dtype=typing.Optional[typing.Dict[str,
typing.Any]], is_attribute=False)
sealed: QbField('sealed', dtype=<class 'bool'>, is_attribute=True)
user: QbNumericField('user', dtype=typing.Optional[int], is_attribute=False)
uuid: QbStrField('uuid', dtype=typing.Optional[str], is_attribute=False)
attributes: QbAttributesField('attributes', dtype=<class 'aiida.orm.nodes.process.process.ProcessNode.AttributesModel'>,
doc='The node attributes')
computer: QbNumericField('computer', dtype=int | None, doc='The PK of the computer')
ctime: QbNumericField('ctime', dtype=<class 'datetime.datetime'>, doc='The creation
time of the node')
description: QbStrField('description', dtype=<class 'str'>, doc='The node description')
exception: QbStrField('attributes.exception', dtype=str | None, doc='The process exception
message')
exit_message: QbStrField('attributes.exit_message', dtype=str | None, doc='The process
exit message')
exit_status: QbNumericField('attributes.exit_status', dtype=int | None, doc='The process
exit status')
extras: QbDictField('extras', dtype=dict[str, typing.Any], doc='The node extras')
label: QbStrField('label', dtype=<class 'str'>, doc='The node label')
mtime: QbNumericField('mtime', dtype=<class 'datetime.datetime'>, doc='The modification
time of the node')
node_type: QbStrField('node_type', dtype=<class 'str'>, doc='The type of the node.')
paused: QbAnyField('attributes.paused', dtype=bool | None, doc='Whether the process
is paused')
pk: QbNumericField('pk', dtype=<class 'int'>, doc='The primary key of the entity')
process_label: QbStrField('attributes.process_label', dtype=str | None, doc='The process
label')
process_state: QbStrField('attributes.process_state', dtype=str | None, doc='The process
state enum')
process_status: QbStrField('attributes.process_status', dtype=str | None, doc='The
process status is a generic status message')
process_type: QbStrField('process_type', dtype=str | None, doc='The process type of
the node')
repository_metadata: QbDictField('repository_metadata', dtype=dict[str, typing.Any],
doc='Virtual hierarchy of the file repository')
sealed: QbAnyField('attributes.sealed', dtype=<class 'bool'>, doc='Whether the node
is sealed')
user: QbNumericField('user', dtype=<class 'int'>, doc='The PK of the user who owns
the node')
uuid: QbAnyField('uuid', dtype=<class 'uuid.UUID'>, doc='The UUID of the node')
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
attributes:
QbDictField('attributes', dtype=typing.Optional[typing.Dict[str, typing.Any]],
is_attribute=False, is_subscriptable=True)
computer: QbNumericField('computer', dtype=typing.Optional[str], is_attribute=False)
ctime: QbNumericField('ctime', dtype=typing.Optional[datetime.datetime], is_attribute=False)
description: QbStrField('description', dtype=typing.Optional[str], is_attribute=False)
exception: QbStrField('exception', dtype=typing.Optional[str], is_attribute=True)
exit_message: QbStrField('exit_message', dtype=typing.Optional[str], is_attribute=True)
exit_status: QbNumericField('exit_status', dtype=typing.Optional[int], is_attribute=True)
extras:
QbDictField('extras', dtype=typing.Optional[typing.Dict[str, typing.Any]],
is_attribute=False, is_subscriptable=True)
label: QbStrField('label', dtype=typing.Optional[str], is_attribute=False)
mtime: QbNumericField('mtime', dtype=typing.Optional[datetime.datetime], is_attribute=False)
node_type: QbStrField('node_type', dtype=typing.Optional[str], is_attribute=False)
paused: QbField('paused', dtype=<class 'bool'>, is_attribute=True)
pk: QbNumericField('pk', dtype=typing.Optional[int], is_attribute=False)
process_label: QbStrField('process_label', dtype=typing.Optional[str], is_attribute=True)
process_state: QbStrField('process_state', dtype=typing.Optional[str], is_attribute=True)
process_status: QbStrField('process_status', dtype=typing.Optional[str], is_attribute=True)
process_type: QbStrField('process_type', dtype=typing.Optional[str], is_attribute=False)
repository_content:
QbDictField('repository_content', dtype=typing.Optional[dict[str,
bytes]], is_attribute=False)
repository_metadata:
QbDictField('repository_metadata', dtype=typing.Optional[typing.Dict[str,
typing.Any]], is_attribute=False)
sealed: QbField('sealed', dtype=<class 'bool'>, is_attribute=True)
user: QbNumericField('user', dtype=typing.Optional[int], is_attribute=False)
uuid: QbStrField('uuid', dtype=typing.Optional[str], is_attribute=False)
attributes: QbAttributesField('attributes', dtype=<class 'aiida.orm.nodes.process.calculation.calculation.CalculationNode.AttributesModel'>,
doc='The node attributes')
computer: QbNumericField('computer', dtype=int | None, doc='The PK of the computer')
ctime: QbNumericField('ctime', dtype=<class 'datetime.datetime'>, doc='The creation
time of the node')
description: QbStrField('description', dtype=<class 'str'>, doc='The node description')
exception: QbStrField('attributes.exception', dtype=str | None, doc='The process exception
message')
exit_message: QbStrField('attributes.exit_message', dtype=str | None, doc='The process
exit message')
exit_status: QbNumericField('attributes.exit_status', dtype=int | None, doc='The process
exit status')
extras: QbDictField('extras', dtype=dict[str, typing.Any], doc='The node extras')
label: QbStrField('label', dtype=<class 'str'>, doc='The node label')
mtime: QbNumericField('mtime', dtype=<class 'datetime.datetime'>, doc='The modification
time of the node')
node_type: QbStrField('node_type', dtype=typing.Literal['process.calculation.CalculationNode.'],
doc='The type of the node.')
paused: QbAnyField('attributes.paused', dtype=bool | None, doc='Whether the process
is paused')
pk: QbNumericField('pk', dtype=<class 'int'>, doc='The primary key of the entity')
process_label: QbStrField('attributes.process_label', dtype=str | None, doc='The process
label')
process_state: QbStrField('attributes.process_state', dtype=str | None, doc='The process
state enum')
process_status: QbStrField('attributes.process_status', dtype=str | None, doc='The
process status is a generic status message')
process_type: QbStrField('process_type', dtype=str | None, doc='The process type of
the node')
repository_metadata: QbDictField('repository_metadata', dtype=dict[str, typing.Any],
doc='Virtual hierarchy of the file repository')
sealed: QbAnyField('attributes.sealed', dtype=<class 'bool'>, doc='Whether the node
is sealed')
user: QbNumericField('user', dtype=<class 'int'>, doc='The PK of the user who owns
the node')
uuid: QbAnyField('uuid', dtype=<class 'uuid.UUID'>, doc='The UUID of the node')
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
attributes:
QbDictField('attributes', dtype=typing.Optional[typing.Dict[str, typing.Any]],
is_attribute=False, is_subscriptable=True)
computer: QbNumericField('computer', dtype=typing.Optional[str], is_attribute=False)
ctime: QbNumericField('ctime', dtype=typing.Optional[datetime.datetime], is_attribute=False)
description: QbStrField('description', dtype=typing.Optional[str], is_attribute=False)
exception: QbStrField('exception', dtype=typing.Optional[str], is_attribute=True)
exit_message: QbStrField('exit_message', dtype=typing.Optional[str], is_attribute=True)
exit_status: QbNumericField('exit_status', dtype=typing.Optional[int], is_attribute=True)
extras:
QbDictField('extras', dtype=typing.Optional[typing.Dict[str, typing.Any]],
is_attribute=False, is_subscriptable=True)
label: QbStrField('label', dtype=typing.Optional[str], is_attribute=False)
mtime: QbNumericField('mtime', dtype=typing.Optional[datetime.datetime], is_attribute=False)
node_type: QbStrField('node_type', dtype=typing.Optional[str], is_attribute=False)
paused: QbField('paused', dtype=<class 'bool'>, is_attribute=True)
pk: QbNumericField('pk', dtype=typing.Optional[int], is_attribute=False)
process_label: QbStrField('process_label', dtype=typing.Optional[str], is_attribute=True)
process_state: QbStrField('process_state', dtype=typing.Optional[str], is_attribute=True)
process_status: QbStrField('process_status', dtype=typing.Optional[str], is_attribute=True)
process_type: QbStrField('process_type', dtype=typing.Optional[str], is_attribute=False)
repository_content:
QbDictField('repository_content', dtype=typing.Optional[dict[str,
bytes]], is_attribute=False)
repository_metadata:
QbDictField('repository_metadata', dtype=typing.Optional[typing.Dict[str,
typing.Any]], is_attribute=False)
sealed: QbField('sealed', dtype=<class 'bool'>, is_attribute=True)
user: QbNumericField('user', dtype=typing.Optional[int], is_attribute=False)
uuid: QbStrField('uuid', dtype=typing.Optional[str], is_attribute=False)
attributes: QbAttributesField('attributes', dtype=<class 'aiida.orm.nodes.process.calculation.calcfunction.CalcFunctionNode.AttributesModel'>,
doc='The node attributes')
computer: QbNumericField('computer', dtype=int | None, doc='The PK of the computer')
ctime: QbNumericField('ctime', dtype=<class 'datetime.datetime'>, doc='The creation
time of the node')
description: QbStrField('description', dtype=<class 'str'>, doc='The node description')
exception: QbStrField('attributes.exception', dtype=str | None, doc='The process exception
message')
exit_message: QbStrField('attributes.exit_message', dtype=str | None, doc='The process
exit message')
exit_status: QbNumericField('attributes.exit_status', dtype=int | None, doc='The process
exit status')
extras: QbDictField('extras', dtype=dict[str, typing.Any], doc='The node extras')
label: QbStrField('label', dtype=<class 'str'>, doc='The node label')
mtime: QbNumericField('mtime', dtype=<class 'datetime.datetime'>, doc='The modification
time of the node')
node_type: QbStrField('node_type', dtype=typing.Literal['process.calculation.calcfunction.CalcFunctionNode.'],
doc='The type of the node.')
paused: QbAnyField('attributes.paused', dtype=bool | None, doc='Whether the process
is paused')
pk: QbNumericField('pk', dtype=<class 'int'>, doc='The primary key of the entity')
process_label: QbStrField('attributes.process_label', dtype=str | None, doc='The process
label')
process_state: QbStrField('attributes.process_state', dtype=str | None, doc='The process
state enum')
process_status: QbStrField('attributes.process_status', dtype=str | None, doc='The
process status is a generic status message')
process_type: QbStrField('process_type', dtype=str | None, doc='The process type of
the node')
repository_metadata: QbDictField('repository_metadata', dtype=dict[str, typing.Any],
doc='Virtual hierarchy of the file repository')
sealed: QbAnyField('attributes.sealed', dtype=<class 'bool'>, doc='Whether the node
is sealed')
user: QbNumericField('user', dtype=<class 'int'>, doc='The PK of the user who owns
the node')
uuid: QbAnyField('uuid', dtype=<class 'uuid.UUID'>, doc='The UUID of the node')
Loading
Loading