-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle dangling nodes in links/groups for legacy_to_main
- Loading branch information
1 parent
8078d99
commit f0991b3
Showing
4 changed files
with
51 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
########################################################################### | ||
# Copyright (c), The AiiDA team. All rights reserved. # | ||
# This file is part of the AiiDA code. # | ||
# # | ||
# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # | ||
# For further information on the license, see the LICENSE.txt file # | ||
# For further information please visit http://www.aiida.net # | ||
########################################################################### | ||
"""Test archive file migration from legacy format (JSON) to main format (SQLite).""" | ||
import pytest | ||
|
||
from aiida.common.exceptions import StorageMigrationError | ||
from aiida.storage.sqlite_zip.migrator import migrate | ||
from tests.utils.archives import get_archive_file | ||
|
||
|
||
def test_dangling_links(tmp_path): | ||
"""Test that links with node UUIDs that are not in the archive are correctly handled.""" | ||
filepath_archive = get_archive_file('0.10_dangling_link.aiida', 'export/migrate') | ||
with pytest.raises(StorageMigrationError, match='Database contains link with unknown input node'): | ||
migrate(filepath_archive, tmp_path / 'archive.aiida', 'main_0001') | ||
|
||
|
||
def test_missing_nodes_in_groups(tmp_path, aiida_caplog): | ||
"""Test that groups with listed node UUIDs that are not in the archive are correctly handled.""" | ||
filepath_archive = get_archive_file('0.10_unknown_nodes_in_group.aiida', 'export/migrate') | ||
migrate(filepath_archive, tmp_path / 'archive.aiida', 'main_0001') | ||
assert 'Dropped unknown nodes in groups' in aiida_caplog.text, aiida_caplog.text |