def test_run__error_log__node_error(tmp_path, exception): temp = tmp_path / "xTMPx" mock = Mock() cfg_mock = Mock(temp_root=tmp_path) node_mock = Node() node_mock._create_temp_dir = mock._create_temp_dir node_mock._create_temp_dir.return_value = temp node_mock._run = mock._run node_mock._run.side_effect = exception("ARGH!") os.mkdir(temp) with pytest.raises(NodeError): node_mock.run(cfg_mock) log_file = tmp_path / "xTMPx" / "pipe.errors" assert log_file.exists() assert "Errors =" in log_file.read_text() assert mock.mock_calls == [ call._create_temp_dir(cfg_mock), call._run(cfg_mock, temp), ]
def test_run__order(): cfg_mock = Mock(temp_root=_DUMMY_TEMP_ROOT) node_mock = Mock() node = Node() node._create_temp_dir = node_mock._create_temp_dir node._create_temp_dir.return_value = _DUMMY_TEMP node._setup = node_mock._setup node._run = node_mock._run node._teardown = node_mock._teardown node._remove_temp_dir = node_mock._remove_temp_dir node.run(cfg_mock) node_mock.mock_calls == [ call._create_temp_dir(cfg_mock), call._setup(cfg_mock, _DUMMY_TEMP), call._run(cfg_mock, _DUMMY_TEMP), call._teardown(cfg_mock, _DUMMY_TEMP), call._remove_temp_dir(_DUMMY_TEMP), ]