@@ -274,6 +274,38 @@ def test_backdropNode_customSerialization(self):
274274 assert backdrop .color == "#FF0000"
275275 assert backdrop .comment == "hello world"
276276
277+ def test_backdropNode_templateSerialization (self ):
278+ """ Test that a graph with a backdrop node can be saved as a template. """
279+ g = Graph ("Backdrop node template serialization" )
280+ backdrop = g .addNewNode ("Backdrop" )
281+
282+ # Save the graph as a template
283+ templateFile = os .path .join (tempfile .mkdtemp (), "test_backdrop_template.mg" )
284+ g .save (templateFile , template = True )
285+
286+ # Reload the graph and check both nodes are present
287+ g = loadGraph (templateFile )
288+ assert g .node ("Backdrop_1" ) is not None
289+
290+ def test_backdropNode_templateSerialization_customAttributes (self ):
291+ """ Test that a backdrop node with custom values is correctly saved as a template. """
292+ g = Graph ("Backdrop node template custom serialization" )
293+ backdrop = g .addNewNode ("Backdrop" )
294+
295+ # Set custom values
296+ backdrop .internalAttribute ("nodeWidth" ).value = 400
297+ backdrop .internalAttribute ("comment" ).value = "Template backdrop"
298+
299+ templateFile = os .path .join (tempfile .mkdtemp (), "test_backdrop_template_custom.mg" )
300+ g .save (templateFile , template = True )
301+
302+ # Reload and verify custom values are preserved
303+ g = loadGraph (templateFile )
304+ backdrop = g .node ("Backdrop_1" )
305+ assert backdrop is not None
306+ assert backdrop .nodeWidth == 400
307+ assert backdrop .comment == "Template backdrop"
308+
277309
278310class TestResourceLevels :
279311 """ Test that cpu, gpu, and ram descriptor attributes support both static Level values and callables. """
0 commit comments