Skip to content

Commit be5d0c5

Browse files
cfsmp3claude
andcommitted
fix(test): Mock os.chmod and _verify_binary_commit in test_start_test
The test was failing because os.chmod was called on a non-existent file path and _verify_binary_commit would try to execute the binary. Added mocks for both to make the test work with the new binary verification code. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9483530 commit be5d0c5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/test_ci/test_controllers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,10 @@ def test_cron_job_testing_true(self, mock_gcp_instance, mock_get_compute_service
209209
@mock.patch('mod_ci.controllers.g')
210210
@mock.patch('mod_ci.controllers.TestProgress')
211211
@mock.patch('mod_ci.controllers.GcpInstance')
212-
def test_start_test(self, mock_gcp_instance, mock_test_progress, mock_g, mock_open_file,
212+
@mock.patch('mod_ci.controllers._verify_binary_commit')
213+
@mock.patch('os.chmod')
214+
def test_start_test(self, mock_chmod, mock_verify_binary_commit, mock_gcp_instance,
215+
mock_test_progress, mock_g, mock_open_file,
213216
mock_create_instance, mock_wait_for_operation):
214217
"""Test start_test function."""
215218
import zipfile
@@ -252,6 +255,9 @@ def extractall(*args, **kwargs):
252255
g.db.add(customized_test)
253256
g.db.commit()
254257

258+
# Mock binary verification to succeed
259+
mock_verify_binary_commit.return_value = (True, "Binary commit verified")
260+
255261
# Test when gcp create instance fails
256262
mock_wait_for_operation.return_value = 'error occurred'
257263
start_test(mock.ANY, self.app, mock_g.db, repository, test, mock.ANY)

0 commit comments

Comments
 (0)