main
py 39 lines 1.39 KB
Raw
1 # Copyright 2026 Google LLC
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 import pytest
16 from unittest.mock import MagicMock
17
18
19 @pytest.fixture(autouse=True)
20 def mock_common_state(mocker):
21 # Patch the state singleton in common.py
22 mock_state = mocker.patch("colab_cli.common.state")
23
24 # Setup standard mocks for properties
25 mock_state.store = MagicMock()
26 mock_state.client = MagicMock()
27 mock_state.history = MagicMock()
28
29 # Default behavior for sync_sessions
30 mock_state.sync_sessions.return_value = ({}, [])
31
32 # Global patch for ColabRuntime to prevent network calls
33 # We patch it in the modules where it is imported and used
34 mocker.patch("colab_cli.commands.session.ColabRuntime")
35 mocker.patch("colab_cli.commands.execution.ColabRuntime")
36 mocker.patch("colab_cli.commands.automation.ColabRuntime")
37 mocker.patch("colab_cli.commands.run.ColabRuntime")
38
39 return mock_state