Skip to content
Open
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
4 changes: 4 additions & 0 deletions mkconcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ def cleanup_script_files():
edges_text = soup.find_all('edge')
nodes_text = soup.find_all('node')

if not nodes_text:
logging.error(f"No nodes found in {GRAPHML_FILE}. Is it a valid GraphML workflow?")
sys.exit(1)

# Store the edges and nodes in a dictionary
edge_label_regex = re.compile(r"0x([a-fA-F0-9]+)_(\S+)")
edges_dict = dict()
Expand Down
32 changes: 32 additions & 0 deletions tests/test_mkconcore_no_nodes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import subprocess
import sys
from pathlib import Path

import pytest

MKCONCORE = Path(__file__).resolve().parent.parent / "mkconcore.py"

EMPTY_GRAPH = (
'<?xml version="1.0"?>\n'
'<graphml xmlns="http://graphml.graphdrawing.org/xmlns">'
'<graph id="G" edgedefault="directed"></graph></graphml>\n'
)


@pytest.mark.parametrize("content", [EMPTY_GRAPH, "this is not xml"])
def test_mkconcore_fails_when_graph_has_no_nodes(tmp_path, content):
wf = tmp_path / "w.graphml"
wf.write_text(content)
src = tmp_path / "src"
src.mkdir()
out = tmp_path / "out"

result = subprocess.run(
[sys.executable, str(MKCONCORE), str(wf), str(src), str(out), "posix"],
cwd=tmp_path,
capture_output=True,
text=True,
)

assert result.returncode != 0
assert "No nodes found" in result.stdout + result.stderr
Loading