@@ -70,18 +70,21 @@ def test_check_and_push_branch(self, mock_confirm, mock_isatty, mock_repo):
7070 mock_repo_instance .active_branch .name = "test-branch"
7171 mock_repo_instance .refs = []
7272
73- mock_origin = mock_repo_instance .remote .return_value
74- mock_origin .push .return_value = None
73+ # Mock remotes to return a list with 'origin'
74+ mock_remote_obj = mock_repo_instance .remote .return_value
75+ mock_remote_obj .name = "origin"
76+ mock_remote_obj .push .return_value = None
77+ mock_repo_instance .remotes = [mock_remote_obj ]
7578
7679 assert check_and_push_branch (mock_repo_instance )
77- mock_origin .push .assert_called_once_with (mock_repo_instance .active_branch )
78- mock_origin .push .reset_mock ()
80+ mock_remote_obj .push .assert_called_once_with (mock_repo_instance .active_branch )
81+ mock_remote_obj .push .reset_mock ()
7982
8083 # Test when branch is already pushed
8184 mock_repo_instance .refs = [f"origin/{ mock_repo_instance .active_branch .name } " ]
8285 assert check_and_push_branch (mock_repo_instance )
83- mock_origin .push .assert_not_called ()
84- mock_origin .push .reset_mock ()
86+ mock_remote_obj .push .assert_not_called ()
87+ mock_remote_obj .push .reset_mock ()
8588
8689 @patch ("codeflash.code_utils.git_utils.git.Repo" )
8790 @patch ("codeflash.code_utils.git_utils.sys.__stdin__.isatty" , return_value = False )
@@ -90,12 +93,15 @@ def test_check_and_push_branch_non_tty(self, mock_isatty, mock_repo):
9093 mock_repo_instance .active_branch .name = "test-branch"
9194 mock_repo_instance .refs = []
9295
93- mock_origin = mock_repo_instance .remote .return_value
94- mock_origin .push .return_value = None
96+ # Mock remotes to return a list with 'origin'
97+ mock_remote_obj = mock_repo_instance .remote .return_value
98+ mock_remote_obj .name = "origin"
99+ mock_remote_obj .push .return_value = None
100+ mock_repo_instance .remotes = [mock_remote_obj ]
95101
96102 assert not check_and_push_branch (mock_repo_instance )
97- mock_origin .push .assert_not_called ()
98- mock_origin .push .reset_mock ()
103+ mock_remote_obj .push .assert_not_called ()
104+ mock_remote_obj .push .reset_mock ()
99105
100106
101107if __name__ == "__main__" :
0 commit comments