Skip to content

Commit 5dcb71b

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 da1824b commit 5dcb71b

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
@@ -219,7 +219,10 @@ def test_cron_job_empty_token(self, mock_log):
219219
@mock.patch('mod_ci.controllers.g')
220220
@mock.patch('mod_ci.controllers.TestProgress')
221221
@mock.patch('mod_ci.controllers.GcpInstance')
222-
def test_start_test(self, mock_gcp_instance, mock_test_progress, mock_g, mock_open_file,
222+
@mock.patch('mod_ci.controllers._verify_binary_commit')
223+
@mock.patch('os.chmod')
224+
def test_start_test(self, mock_chmod, mock_verify_binary_commit, mock_gcp_instance,
225+
mock_test_progress, mock_g, mock_open_file,
223226
mock_create_instance, mock_wait_for_operation):
224227
"""Test start_test function."""
225228
import zipfile
@@ -266,6 +269,9 @@ def extractall(*args, **kwargs):
266269
mock_query = create_mock_db_query(mock_g)
267270
mock_query.c.got = MagicMock()
268271

272+
# Mock binary verification to succeed
273+
mock_verify_binary_commit.return_value = (True, "Binary commit verified")
274+
269275
# Test when gcp create instance fails
270276
mock_wait_for_operation.return_value = 'error occurred'
271277
start_test(mock.ANY, self.app, mock_g.db, repository, test, mock.ANY)

0 commit comments

Comments
 (0)