77runner = CliRunner ()
88
99
10+ def create_mock_config (includes_list = None ):
11+ if includes_list is None :
12+ includes_list = []
13+
14+ mock_pyproject_config = MagicMock ()
15+
16+ mock_tool_comfy_section = MagicMock ()
17+ mock_tool_comfy_section .name = "test-node"
18+ mock_tool_comfy_section .version = "0.1.0"
19+ mock_tool_comfy_section .description = "A test node."
20+ mock_tool_comfy_section .author = "Test Author"
21+ mock_tool_comfy_section .license = "MIT"
22+ mock_tool_comfy_section .tags = ["test" ]
23+ mock_tool_comfy_section .repository = "http://example.com/repo"
24+ mock_tool_comfy_section .homepage = "http://example.com/home"
25+ mock_tool_comfy_section .documentation = "http://example.com/docs"
26+ mock_tool_comfy_section .includes = includes_list
27+
28+ mock_pyproject_config .tool_comfy = mock_tool_comfy_section
29+
30+ return mock_pyproject_config
31+
32+
1033def test_publish_fails_on_security_violations ():
1134 # Mock subprocess.run to simulate security violations
1235 mock_result = MagicMock ()
@@ -40,7 +63,8 @@ def test_publish_continues_on_no_security_violations():
4063 patch ("comfy_cli.command.custom_nodes.command.upload_file_to_signed_url" ) as mock_upload ,
4164 ):
4265 # Setup the mocks
43- mock_extract .return_value = {"name" : "test-node" }
66+ mock_extract .return_value = create_mock_config ()
67+
4468 mock_prompt .return_value = "test-token"
4569 mock_publish .return_value = MagicMock (signedUrl = "https://test.url" )
4670
@@ -76,7 +100,8 @@ def test_publish_with_token_option():
76100 patch ("comfy_cli.command.custom_nodes.command.upload_file_to_signed_url" ) as mock_upload ,
77101 ):
78102 # Setup the mocks
79- mock_extract .return_value = {"name" : "test-node" }
103+ mock_extract .return_value = create_mock_config ()
104+
80105 mock_publish .return_value = MagicMock (signedUrl = "https://test.url" )
81106
82107 # Run the publish command with token
@@ -104,7 +129,8 @@ def test_publish_exits_on_upload_failure():
104129 patch ("comfy_cli.command.custom_nodes.command.upload_file_to_signed_url" ) as mock_upload ,
105130 ):
106131 # Setup the mocks
107- mock_extract .return_value = {"name" : "test-node" }
132+ mock_extract .return_value = create_mock_config ()
133+
108134 mock_publish .return_value = MagicMock (signedUrl = "https://test.url" )
109135 mock_upload .side_effect = Exception ("Upload failed with status code: 403" )
110136
@@ -117,3 +143,33 @@ def test_publish_exits_on_upload_failure():
117143 assert mock_publish .called
118144 assert mock_zip .called
119145 assert mock_upload .called
146+
147+
148+ def test_publish_with_includes_parameter ():
149+ # Mock subprocess.run to simulate no violations
150+ mock_result = MagicMock ()
151+ mock_result .returncode = 0
152+ mock_result .stdout = ""
153+
154+ with (
155+ patch ("subprocess.run" , return_value = mock_result ),
156+ patch ("comfy_cli.command.custom_nodes.command.extract_node_configuration" ) as mock_extract ,
157+ patch ("comfy_cli.command.custom_nodes.command.registry_api.publish_node_version" ) as mock_publish ,
158+ patch ("comfy_cli.command.custom_nodes.command.zip_files" ) as mock_zip ,
159+ patch ("comfy_cli.command.custom_nodes.command.upload_file_to_signed_url" ) as mock_upload ,
160+ ):
161+ includes = ["/js" , "/dist" ]
162+
163+ # Setup the mocks
164+ mock_extract .return_value = create_mock_config (includes )
165+
166+ mock_publish .return_value = MagicMock (signedUrl = "https://test.url" )
167+
168+ # Run the publish command with token
169+ _result = runner .invoke (app , ["publish" , "--token" , "test-token" ])
170+
171+ # Verify the publish flow worked with provided token
172+ assert mock_extract .called
173+ assert mock_publish .called
174+ assert mock_zip .called
175+ assert mock_upload .called
0 commit comments