2
2
3
3
import shutil
4
4
from pathlib import Path
5
- from unittest .mock import patch
5
+ from unittest .mock import MagicMock , patch
6
6
7
7
import pytest
8
8
@@ -26,12 +26,15 @@ def test_preprocess_config_not_found(cli_runner):
26
26
def test_preprocess_basic (cli_runner , config_path ):
27
27
"""Test basic preprocessing with minimal config"""
28
28
with patch ("axolotl.cli.preprocess.do_cli" ) as mock_do_cli :
29
- result = cli_runner . invoke ( cli , [ " preprocess" , str ( config_path )])
30
- assert result . exit_code == 0
29
+ with patch ( "axolotl.cli. preprocess.load_datasets" ) as mock_load_datasets :
30
+ mock_load_datasets . return_value = MagicMock ()
31
31
32
- mock_do_cli .assert_called_once ()
33
- assert mock_do_cli .call_args .kwargs ["config" ] == str (config_path )
34
- assert mock_do_cli .call_args .kwargs ["download" ] is True
32
+ result = cli_runner .invoke (cli , ["preprocess" , str (config_path )])
33
+ assert result .exit_code == 0
34
+
35
+ mock_do_cli .assert_called_once ()
36
+ assert mock_do_cli .call_args .kwargs ["config" ] == str (config_path )
37
+ assert mock_do_cli .call_args .kwargs ["download" ] is True
35
38
36
39
37
40
def test_preprocess_without_download (cli_runner , config_path ):
@@ -54,19 +57,22 @@ def test_preprocess_custom_path(cli_runner, tmp_path, valid_test_config):
54
57
config_path .write_text (valid_test_config )
55
58
56
59
with patch ("axolotl.cli.preprocess.do_cli" ) as mock_do_cli :
57
- result = cli_runner .invoke (
58
- cli ,
59
- [
60
- "preprocess" ,
61
- str (config_path ),
62
- "--dataset-prepared-path" ,
63
- str (custom_path .absolute ()),
64
- ],
65
- )
66
- assert result .exit_code == 0
67
-
68
- mock_do_cli .assert_called_once ()
69
- assert mock_do_cli .call_args .kwargs ["config" ] == str (config_path )
70
- assert mock_do_cli .call_args .kwargs ["dataset_prepared_path" ] == str (
71
- custom_path .absolute ()
72
- )
60
+ with patch ("axolotl.cli.preprocess.load_datasets" ) as mock_load_datasets :
61
+ mock_load_datasets .return_value = MagicMock ()
62
+
63
+ result = cli_runner .invoke (
64
+ cli ,
65
+ [
66
+ "preprocess" ,
67
+ str (config_path ),
68
+ "--dataset-prepared-path" ,
69
+ str (custom_path .absolute ()),
70
+ ],
71
+ )
72
+ assert result .exit_code == 0
73
+
74
+ mock_do_cli .assert_called_once ()
75
+ assert mock_do_cli .call_args .kwargs ["config" ] == str (config_path )
76
+ assert mock_do_cli .call_args .kwargs ["dataset_prepared_path" ] == str (
77
+ custom_path .absolute ()
78
+ )
0 commit comments