File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ from unittest .mock import AsyncMock , patch
2+
3+ import pytest
4+
5+ from vectorcode .cli_utils import CliAction , Config , FilesAction
6+ from vectorcode .subcommands .files import files
7+
8+
9+ @pytest .mark .asyncio
10+ async def test_files ():
11+ with patch (
12+ "vectorcode.subcommands.files.ls.ls" , return_value = AsyncMock ()
13+ ) as mock_ls :
14+ config = Config (action = CliAction .files , files_action = FilesAction .ls )
15+ await files (config )
16+ mock_ls .assert_called_with (config )
17+ with patch (
18+ "vectorcode.subcommands.files.rm.rm" , return_value = AsyncMock ()
19+ ) as mock_rm :
20+ config = Config (action = CliAction .files , files_action = FilesAction .rm )
21+ await files (config )
22+ mock_rm .assert_called_with (config )
23+
24+
25+ @pytest .mark .asyncio
26+ async def test_files_invalid_actions ():
27+ with patch ("vectorcode.subcommands.files.logger" ) as mock_logger :
28+ config = Config (action = CliAction .files , files_action = "foobar" )
29+ assert await files (config ) != 0
30+ mock_logger .error .assert_called_once ()
You can’t perform that action at this time.
0 commit comments