@@ -140,7 +140,37 @@ def test_workflow_json_generation(self):
140140 # Compare the two jsons!
141141 assert (original_json == written_json )
142142
143+ @pytest .mark .unit
144+ def test_workflow_dot_file (self ):
145+
146+ # Put a JSON file in /tmp
147+ url = "https://raw.githubusercontent.com/wfcommons/WfInstances/refs/heads/main/makeflow/blast/blast-chameleon-small-001.json"
148+ response = requests .get (url )
149+ local_file_name = url .split ("/" )[- 1 ]
150+ with open ("/tmp/" + local_file_name , 'wb' ) as f :
151+ f .write (response .content )
152+
153+ # Create an instance from the JSON File and write it back to a JSON
154+ instance = Instance (pathlib .Path ("/tmp" ) / local_file_name )
143155
156+ # Capture some metrics
157+ num_tasks = len (instance .workflow .tasks )
158+ num_dependencies = len (instance .workflow .edges )
159+
160+ # # Create a dot file
161+ dot_path = pathlib .Path ("/tmp/written_workflow.dot" )
162+ instance .workflow .write_dot (dot_path )
163+ assert dot_path .exists ()
164+ with open (str (dot_path ), "r" , encoding = "utf-8" ) as f :
165+ content = f .read ()
166+ assert (num_tasks == content .count ("label" ) - 1 ) # Extra "label" in file for \N
167+ assert (num_dependencies == content .count ("->" )) # Extra "label" in file for \N
168+
169+ # Read it back
170+ instance .workflow .read_dot (dot_path )
171+ assert (num_tasks == len (instance .workflow .tasks ))
172+ assert (num_tasks == len (instance .workflow .nodes ))
173+ assert (num_dependencies == len (instance .workflow .edges ))
144174
145175
146176
0 commit comments