Skip to content

Commit 74954d2

Browse files
authored
Fix ev-flow#380, CLI gives an outdated path to the default ruleset (ev-flow#389)
1 parent d9a8f7a commit 74954d2

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

quark/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"--rule",
6868
help="Rules directory",
6969
type=click.Path(exists=True, file_okay=True, dir_okay=True),
70-
default=f"{config.HOME_DIR}quark-rules",
70+
default=f"{config.DIR_PATH}",
7171
required=False,
7272
show_default=True,
7373
)

quark/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
HOME_DIR = f"{Path.home()}/.quark-engine/"
88
SOURCE = "https://github.com/quark-engine/quark-rules"
9-
DIR_PATH = f"{HOME_DIR}quark-rules"
9+
DIR_PATH = f"{HOME_DIR}quark-rules/rules"
1010

1111
DEBUG = False
1212

quark/freshquark.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def download():
2828
"git",
2929
"clone",
3030
"https://github.com/quark-engine/quark-rules",
31-
config.DIR_PATH,
31+
f"{config.HOME_DIR}quark-rules",
3232
],
3333
stdout=subprocess.PIPE,
3434
stderr=subprocess.PIPE,
@@ -58,7 +58,7 @@ def download():
5858
[
5959
"git",
6060
"-C",
61-
config.DIR_PATH,
61+
f"{config.HOME_DIR}quark-rules",
6262
"pull",
6363
],
6464
stdout=subprocess.PIPE,

tests/test_freshquark.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,36 @@
66
def test_download_without_exist_rules(tmp_path):
77
non_exist_rule_directory = tmp_path / "quark-rules"
88

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}/"
1011

1112
with patch("subprocess.run") as mock:
1213
download()
1314

1415
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+
]
2122

2223

2324
def test_download_with_exist_rules(tmp_path):
2425
exist_rule_directory = tmp_path / "quark-rules"
2526
exist_rule_directory.mkdir()
2627

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}"
2831

2932
with patch("subprocess.run") as mock:
3033
download()
3134

3235
mock.assert_called_once()
3336
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

Comments
 (0)