@@ -393,3 +393,49 @@ def test_folder_depth(self):
393393 _ ,
394394 _ in os .walk (resources_dir ))
395395 self .assertLessEqual (max_depth , 2 )
396+
397+ def test_resources_exist_and_render (self ):
398+ """
399+ Test that resources directory exists and icons can be loaded for rendering.
400+ This ensures the package build includes all necessary resource files.
401+ """
402+ from diagrams .aws .compute import EC2
403+ from diagrams .aws .database import RDS
404+
405+ # Verify resources directory exists
406+ resources_dir = pathlib .Path (__file__ ).parent .parent / "resources"
407+ self .assertTrue (resources_dir .exists (), "resources directory should exist" )
408+
409+ # Verify AWS resources exist (sample check)
410+ aws_compute_dir = resources_dir / "aws" / "compute"
411+ self .assertTrue (aws_compute_dir .exists (), "AWS compute resources should exist" )
412+
413+ # Verify icon files exist
414+ ec2_icon = aws_compute_dir / "ec2.png"
415+ self .assertTrue (ec2_icon .exists (), "EC2 icon should exist" )
416+
417+ # Test that nodes can load their icons
418+ test_diagram_name = "test_resources_render"
419+ try :
420+ with Diagram (test_diagram_name , show = False ):
421+ ec2_node = EC2 ("test-ec2" )
422+ rds_node = RDS ("test-rds" )
423+
424+ # Verify nodes have icon attributes set
425+ self .assertIsNotNone (ec2_node ._icon , "EC2 node should have an icon" )
426+ self .assertIsNotNone (rds_node ._icon , "RDS node should have an icon" )
427+
428+ # Verify icon paths are valid
429+ ec2_icon_path = ec2_node ._load_icon ()
430+ rds_icon_path = rds_node ._load_icon ()
431+
432+ self .assertTrue (os .path .exists (ec2_icon_path ),
433+ f"EC2 icon path should exist: { ec2_icon_path } " )
434+ self .assertTrue (os .path .exists (rds_icon_path ),
435+ f"RDS icon path should exist: { rds_icon_path } " )
436+ finally :
437+ # Clean up generated files
438+ try :
439+ os .remove (test_diagram_name + ".png" )
440+ except FileNotFoundError :
441+ pass
0 commit comments