@@ -24,13 +24,20 @@ def test_init_with_explicit_repo(self, tmp_path):
2424
2525 assert result .exit_code == 0
2626
27- # Check git init was called
28- assert any ('git' in str (call ) and 'init' in str (call ) for call in mock_proc .run .call_args_list )
29-
30- # Check git config calls
31- config_calls = [str (call ) for call in mock_proc .run .call_args_list if 'config' in str (call )]
32- assert any ('pr.owner' in call and 'test-owner' in call for call in config_calls )
33- assert any ('pr.repo' in call and 'test-repo' in call for call in config_calls )
27+ # Extract all git commands called
28+ git_commands = [
29+ call [0 ][0 ] if call [0 ] else None
30+ for call in mock_proc .run .call_args_list
31+ ]
32+ assert 'git' in git_commands
33+
34+ # Find specific git config calls
35+ git_config_calls = [
36+ call [0 ] for call in mock_proc .run .call_args_list
37+ if len (call [0 ]) > 2 and call [0 ][0 ] == 'git' and call [0 ][1 ] == 'config'
38+ ]
39+ assert ('git' , 'config' , 'pr.owner' , 'test-owner' ) in git_config_calls
40+ assert ('git' , 'config' , 'pr.repo' , 'test-repo' ) in git_config_calls
3441
3542 # Check gh/new/ directory and DESCRIPTION.md were created
3643 assert Path ('gh/new' ).is_dir ()
@@ -80,6 +87,7 @@ def test_create_issue_success(self, tmp_path):
8087 patch ('ghpr.commands.create.get_owner_repo' ) as mock_get_repo , \
8188 patch ('ghpr.commands.create.read_description_file' ) as mock_read_desc , \
8289 patch ('ghpr.commands.create.write_description_with_link_ref' ) as mock_write , \
90+ patch ('ghpr.commands.push.push' ) as mock_push , \
8391 patch ('ghpr.commands.create.err' ), \
8492 patch ('os.rename' ):
8593
@@ -89,19 +97,19 @@ def test_create_issue_success(self, tmp_path):
8997
9098 create_new_issue (repo_arg = None , yes = 2 , dry_run = False )
9199
92- # Verify gh issue create was called
100+ # Verify gh issue create was called with exact arguments
93101 mock_proc .text .assert_called_once ()
94102 call_args = mock_proc .text .call_args [0 ]
95- assert 'gh' in call_args
96- assert 'issue' in call_args
97- assert 'create' in call_args
98- assert '--title' in call_args
99- assert 'Test Issue' in call_args
103+ expected_args = ('gh' , 'issue' , 'create' , '-R' , 'test-owner/test-repo' , '--title' , 'Test Issue' , '--body' , 'Test body content' )
104+ assert call_args == expected_args
100105
101- # Verify git config was set
102- config_calls = [call [0 ] for call in mock_proc .run .call_args_list if 'config' in call [0 ]]
103- assert any ('pr.number' in call and '42' in call for call in config_calls )
104- assert any ('pr.type' in call and 'issue' in call for call in config_calls )
106+ # Verify git config was set with exact calls
107+ config_calls = [
108+ call [0 ] for call in mock_proc .run .call_args_list
109+ if len (call [0 ]) > 1 and call [0 ][0 ] == 'git' and call [0 ][1 ] == 'config'
110+ ]
111+ assert ('git' , 'config' , 'pr.number' , '42' ) in config_calls
112+ assert ('git' , 'config' , 'pr.type' , 'issue' ) in config_calls
105113
106114 # Verify file was written with link reference
107115 mock_write .assert_called_once ()
@@ -120,6 +128,7 @@ def test_create_issue_with_explicit_repo(self, tmp_path):
120128 patch ('ghpr.commands.create.get_owner_repo' ) as mock_get_repo , \
121129 patch ('ghpr.commands.create.read_description_file' ) as mock_read_desc , \
122130 patch ('ghpr.commands.create.write_description_with_link_ref' ), \
131+ patch ('ghpr.commands.push.push' ), \
123132 patch ('ghpr.commands.create.err' ), \
124133 patch ('os.rename' ):
125134
@@ -151,6 +160,7 @@ def test_create_pr_with_explicit_args(self, tmp_path):
151160 with patch ('ghpr.commands.create.proc' ) as mock_proc , \
152161 patch ('ghpr.commands.create.read_description_file' ) as mock_read_desc , \
153162 patch ('ghpr.commands.create.write_description_with_link_ref' ) as mock_write , \
163+ patch ('ghpr.commands.push.push' ), \
154164 patch ('ghpr.commands.create.err' ), \
155165 patch ('os.rename' ):
156166
@@ -177,16 +187,18 @@ def line_side_effect(*args, **kwargs):
177187 dry_run = False
178188 )
179189
180- # Verify gh pr create was called with correct args
190+ # Verify gh pr create was called with exact arguments
181191 mock_proc .text .assert_called_once ()
182192 call_args = mock_proc .text .call_args [0 ]
183- assert 'gh' in call_args
184- assert 'pr' in call_args
185- assert 'create' in call_args
186- assert '--head' in call_args
187- assert 'feature-branch' in call_args
188- assert '--base' in call_args
189- assert 'main' in call_args
193+ expected_args = (
194+ 'gh' , 'pr' , 'create' ,
195+ '-R' , 'test-owner/test-repo' ,
196+ '--title' , 'Test PR' ,
197+ '--body' , 'Test body' ,
198+ '--base' , 'main' ,
199+ '--head' , 'feature-branch'
200+ )
201+ assert call_args == expected_args
190202
191203 def test_create_draft_pr (self , tmp_path ):
192204 """Test draft PR includes --draft flag."""
@@ -197,6 +209,7 @@ def test_create_draft_pr(self, tmp_path):
197209 with patch ('ghpr.commands.create.proc' ) as mock_proc , \
198210 patch ('ghpr.commands.create.read_description_file' ) as mock_read_desc , \
199211 patch ('ghpr.commands.create.write_description_with_link_ref' ), \
212+ patch ('ghpr.commands.push.push' ), \
200213 patch ('ghpr.commands.create.err' ), \
201214 patch ('os.rename' ):
202215
@@ -221,6 +234,15 @@ def line_side_effect(*args, **kwargs):
221234 dry_run = False
222235 )
223236
224- # Verify --draft flag was passed
237+ # Verify --draft flag was passed with exact arguments
225238 call_args = mock_proc .text .call_args [0 ]
226- assert '--draft' in call_args
239+ expected_args = (
240+ 'gh' , 'pr' , 'create' ,
241+ '-R' , 'test-owner/test-repo' ,
242+ '--title' , 'Draft PR' ,
243+ '--body' , 'Draft body' ,
244+ '--base' , 'main' ,
245+ '--head' , 'feature' ,
246+ '--draft'
247+ )
248+ assert call_args == expected_args
0 commit comments