Skip to content
Draft
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
5 changes: 3 additions & 2 deletions tests/cmdline/commands/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,11 +687,12 @@ def test_dump_specified_path_message(self, run_cli_command, tmp_path, generate_c
assert result.exception is None, result.output
assert f'Using specified output path: `{test_path}`' in result.output

def test_dump_warning_message_displayed(self, run_cli_command, generate_calculation_node_add):
def test_dump_warning_message_displayed(self, run_cli_command, tmp_path, generate_calculation_node_add):
"""Test that warning message about new feature is displayed"""
test_path = tmp_path / 'specified-path'
node = generate_calculation_node_add()

options = [str(node.pk)]
options = [str(node.pk), '--path', str(test_path)]
result = run_cli_command(cmd_process.process_dump, options)
assert result.exception is None, result.output
assert 'This is a new feature which is still in its testing phase' in result.output
Expand Down
28 changes: 20 additions & 8 deletions tests/orm/nodes/data/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"""Tests for the :class:`aiida.orm.nodes.data.data:Data` class."""

import os
import tempfile
from contextlib import contextmanager

import numpy
import pytest
Expand Down Expand Up @@ -176,19 +178,29 @@ def test_constructor():
assert node.source == source


def test_data_exporters(data_plugin, generate_class_instance):
"""Verify that the return value of the export methods of all `Data` sub classes have the correct type.
@contextmanager
def temporary_directory():
"""Context manager that changes to a temporary directory."""
original_cwd = os.getcwd()
with tempfile.TemporaryDirectory() as temp_dir:
try:
os.chdir(temp_dir)
yield temp_dir
finally:
os.chdir(original_cwd)

It should be a tuple where the first should be a byte string and the second a dictionary.
"""

def test_data_exporters(data_plugin, generate_class_instance):
"""Verify that the return value of the export methods of all `Data` sub classes have the correct type."""
export_formats = data_plugin.get_export_formats()

if not export_formats:
return

instance = generate_class_instance(data_plugin)

for fileformat in export_formats:
content, dictionary = instance._exportcontent(fileformat)
assert isinstance(content, bytes)
assert isinstance(dictionary, dict)
with temporary_directory():
for fileformat in export_formats:
content, dictionary = instance._exportcontent(fileformat)
assert isinstance(content, bytes)
assert isinstance(dictionary, dict)