|
6 | 6 | def test_download_without_exist_rules(tmp_path): |
7 | 7 | non_exist_rule_directory = tmp_path / "quark-rules" |
8 | 8 |
|
9 | | - with patch("quark.config.DIR_PATH", non_exist_rule_directory) as _: |
| 9 | + with patch("quark.freshquark.config") as mock_config: |
| 10 | + mock_config.HOME_DIR = f"{tmp_path}/" |
10 | 11 |
|
11 | 12 | with patch("subprocess.run") as mock: |
12 | 13 | download() |
13 | 14 |
|
14 | 15 | mock.assert_called_once() |
15 | | - assert set(mock.call_args[0][0]) == { |
16 | | - "git", |
17 | | - "clone", |
18 | | - "https://github.com/quark-engine/quark-rules", |
19 | | - non_exist_rule_directory, |
20 | | - } |
| 16 | + assert mock.call_args[0][0] == [ |
| 17 | + "git", |
| 18 | + "clone", |
| 19 | + "https://github.com/quark-engine/quark-rules", |
| 20 | + f"{non_exist_rule_directory}" |
| 21 | + ] |
21 | 22 |
|
22 | 23 |
|
23 | 24 | def test_download_with_exist_rules(tmp_path): |
24 | 25 | exist_rule_directory = tmp_path / "quark-rules" |
25 | 26 | exist_rule_directory.mkdir() |
26 | 27 |
|
27 | | - with patch("quark.config.DIR_PATH", exist_rule_directory) as _: |
| 28 | + with patch("quark.freshquark.config") as mock_config: |
| 29 | + mock_config.HOME_DIR = f"{tmp_path}/" |
| 30 | + mock_config.DIR_PATH = f"{exist_rule_directory}" |
28 | 31 |
|
29 | 32 | with patch("subprocess.run") as mock: |
30 | 33 | download() |
31 | 34 |
|
32 | 35 | mock.assert_called_once() |
33 | 36 | assert mock.call_args[0][0] == [ |
34 | | - "git", |
35 | | - "-C", |
36 | | - exist_rule_directory, |
37 | | - "pull", |
38 | | - ] |
| 37 | + "git", |
| 38 | + "-C", |
| 39 | + f"{exist_rule_directory}", |
| 40 | + "pull", |
| 41 | + ] |
0 commit comments