Skip to content

Commit 0b37ef6

Browse files
Update tests
1 parent ee17f94 commit 0b37ef6

File tree

42 files changed

+519
-547
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+519
-547
lines changed

tests/orm/data/code/test_abstract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ def test_serialization():
7272
label = 'some-label'
7373
code = MockCode(label=label)
7474

75-
MockCode.from_serialized(**code.serialize())
75+
MockCode.from_serialized(unstored=True, **code.serialize(unstored=True))

tests/orm/data/code/test_installed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,4 @@ def test_serialization(aiida_localhost, bash_path):
152152
"""Test the deprecated :meth:`aiida.orm.nodes.data.code.installed.InstalledCode.get_execname` method."""
153153
code = InstalledCode(label='some-label', computer=aiida_localhost, filepath_executable=str(bash_path.absolute()))
154154

155-
InstalledCode.from_serialized(**code.serialize())
155+
InstalledCode.from_serialized(unstored=True, **code.serialize(unstored=True))

tests/orm/data/code/test_portable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,4 @@ def test_serialization(tmp_path, chdir_tmp_path):
145145
(filepath_files / 'subdir').mkdir()
146146
(filepath_files / 'subdir/test').write_text('test')
147147
code = PortableCode(label='some-label', filepath_executable='bash', filepath_files=filepath_files)
148-
PortableCode.from_serialized(**code.serialize())
148+
PortableCode.from_serialized(unstored=True, **code.serialize(unstored=True))

tests/orm/models/test_models.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,18 @@ def test_roundtrip(required_arguments, tmp_path):
169169
assert isinstance(entity, cls)
170170

171171
# Get the model instance from the entity instance
172-
model = entity._to_model(tmp_path)
172+
model = entity.to_model(tmp_path, unstored=True)
173173
assert isinstance(model, BaseModel)
174174

175175
# Reconstruct the entity instance from the model instance
176-
roundtrip = cls._from_model(model)
176+
roundtrip = cls.from_model(model)
177177
assert isinstance(roundtrip, cls)
178178

179179
# Get the model instance again from the reconstructed entity and check that the fields that would be passed to the
180180
# ORM entity constructor are identical of the original model. The ``model_to_orm_field_values`` excludes values of
181181
# fields that define ``exclude_to_orm=True`` because these can change during roundtrips. This because these
182182
# typically correspond to entity fields that have defaults set on the database level, e.g., UUIDs.
183-
roundtrip_model = roundtrip._to_model(tmp_path)
183+
roundtrip_model = roundtrip.to_model(tmp_path, unstored=True)
184184
original_field_values = cls.model_to_orm_field_values(model)
185185

186186
for key, value in cls.model_to_orm_field_values(roundtrip_model).items():
@@ -206,5 +206,5 @@ def test_roundtrip_serialization(required_arguments, tmp_path):
206206
assert isinstance(entity, cls)
207207

208208
# Get the model instance from the entity instance
209-
serialized_entity = entity.serialize(tmp_path)
210-
entity.from_serialized(**serialized_entity)
209+
serialized_entity = entity.serialize(tmp_path, unstored=True, mode='python')
210+
entity.from_serialized(unstored=True, **serialized_entity)

tests/orm/test_fields/fields_AuthInfo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ auth_params: QbDictField('auth_params', dtype=typing.Dict[str, typing.Any], is_a
22
computer: QbNumericField('computer', dtype=<class 'int'>, is_attribute=False)
33
enabled: QbField('enabled', dtype=<class 'bool'>, is_attribute=False)
44
metadata: QbDictField('metadata', dtype=typing.Dict[str, typing.Any], is_attribute=False)
5-
pk: QbNumericField('pk', dtype=typing.Optional[int], is_attribute=False)
5+
pk: QbNumericField('pk', dtype=<class 'int'>, is_attribute=False)
66
user: QbNumericField('user', dtype=<class 'int'>, is_attribute=False)
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
content: QbStrField('content', dtype=<class 'str'>, is_attribute=False)
2-
ctime: QbNumericField('ctime', dtype=typing.Optional[datetime.datetime], is_attribute=False)
3-
mtime: QbNumericField('mtime', dtype=typing.Optional[datetime.datetime], is_attribute=False)
2+
ctime: QbNumericField('ctime', dtype=<class 'datetime.datetime'>, is_attribute=False)
3+
mtime: QbNumericField('mtime', dtype=<class 'datetime.datetime'>, is_attribute=False)
44
node: QbNumericField('node', dtype=<class 'int'>, is_attribute=False)
5-
pk: QbNumericField('pk', dtype=typing.Optional[int], is_attribute=False)
5+
pk: QbNumericField('pk', dtype=<class 'int'>, is_attribute=False)
66
user: QbNumericField('user', dtype=<class 'int'>, is_attribute=False)
7-
uuid: QbStrField('uuid', dtype=typing.Optional[str], is_attribute=False)
7+
uuid: QbField('uuid', dtype=<class 'uuid.UUID'>, is_attribute=False)

tests/orm/test_fields/fields_Computer.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ description: QbStrField('description', dtype=<class 'str'>, is_attribute=False)
22
hostname: QbStrField('hostname', dtype=<class 'str'>, is_attribute=False)
33
label: QbStrField('label', dtype=<class 'str'>, is_attribute=False)
44
metadata: QbDictField('metadata', dtype=typing.Dict[str, typing.Any], is_attribute=False)
5-
pk: QbNumericField('pk', dtype=typing.Optional[int], is_attribute=False)
5+
pk: QbNumericField('pk', dtype=<class 'int'>, is_attribute=False)
66
scheduler_type: QbStrField('scheduler_type', dtype=<class 'str'>, is_attribute=False)
77
transport_type: QbStrField('transport_type', dtype=<class 'str'>, is_attribute=False)
8-
uuid: QbStrField('uuid', dtype=<class 'str'>, is_attribute=False)
8+
uuid: QbField('uuid', dtype=<class 'uuid.UUID'>, is_attribute=False)
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
description: QbStrField('description', dtype=typing.Optional[str], is_attribute=False)
2-
extras: QbDictField('extras', dtype=typing.Optional[typing.Dict[str, typing.Any]],
3-
is_attribute=False, is_subscriptable=True)
1+
description: QbStrField('description', dtype=<class 'str'>, is_attribute=False)
2+
extras: QbDictField('extras', dtype=typing.Dict[str, typing.Any], is_attribute=False,
3+
is_subscriptable=True)
44
label: QbStrField('label', dtype=<class 'str'>, is_attribute=False)
5-
pk: QbNumericField('pk', dtype=typing.Optional[int], is_attribute=False)
6-
time: QbNumericField('time', dtype=typing.Optional[datetime.datetime], is_attribute=False)
5+
pk: QbNumericField('pk', dtype=<class 'int'>, is_attribute=False)
6+
time: QbNumericField('time', dtype=<class 'datetime.datetime'>, is_attribute=False)
77
type_string: QbStrField('type_string', dtype=<class 'str'>, is_attribute=False)
88
user: QbNumericField('user', dtype=<class 'int'>, is_attribute=False)
9-
uuid: QbStrField('uuid', dtype=<class 'str'>, is_attribute=False)
9+
uuid: QbField('uuid', dtype=<class 'uuid.UUID'>, is_attribute=False)

tests/orm/test_fields/fields_Log.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ levelname: QbStrField('levelname', dtype=<class 'str'>, is_attribute=False)
33
loggername: QbStrField('loggername', dtype=<class 'str'>, is_attribute=False)
44
message: QbStrField('message', dtype=<class 'str'>, is_attribute=False)
55
metadata: QbDictField('metadata', dtype=typing.Dict[str, typing.Any], is_attribute=False)
6-
pk: QbNumericField('pk', dtype=typing.Optional[int], is_attribute=False)
6+
pk: QbNumericField('pk', dtype=<class 'int'>, is_attribute=False)
77
time: QbNumericField('time', dtype=<class 'datetime.datetime'>, is_attribute=False)
8-
uuid: QbStrField('uuid', dtype=<class 'str'>, is_attribute=False)
8+
uuid: QbField('uuid', dtype=<class 'uuid.UUID'>, is_attribute=False)

tests/orm/test_fields/fields_User.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ email: QbStrField('email', dtype=<class 'str'>, is_attribute=False)
22
first_name: QbStrField('first_name', dtype=<class 'str'>, is_attribute=False)
33
institution: QbStrField('institution', dtype=<class 'str'>, is_attribute=False)
44
last_name: QbStrField('last_name', dtype=<class 'str'>, is_attribute=False)
5-
pk: QbNumericField('pk', dtype=typing.Optional[int], is_attribute=False)
5+
pk: QbNumericField('pk', dtype=<class 'int'>, is_attribute=False)

0 commit comments

Comments
 (0)