-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_get_hooks.py
More file actions
55 lines (42 loc) · 2.11 KB
/
test_get_hooks.py
File metadata and controls
55 lines (42 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import importlib
import sys
from unittest.mock import patch
from slack_cli_hooks.hooks import get_hooks
from slack_cli_hooks.hooks.get_hooks import hooks_payload
class TestGetHooks:
def test_exec_uses_sys_executable(self):
with patch.object(sys, "executable", "/usr/bin/python3"), patch.object(sys, "platform", "linux"):
importlib.reload(get_hooks)
assert get_hooks.EXEC == "'/usr/bin/python3'"
def test_exec_uses_call_operator_on_windows(self):
with patch.object(sys, "executable", "C:\\Python\\python.exe"), patch.object(sys, "platform", "win32"):
importlib.reload(get_hooks)
assert get_hooks.EXEC == "& 'C:\\Python\\python.exe'"
def test_exec_falls_back_to_python_when_sys_executable_is_empty(self):
with patch.object(sys, "executable", ""):
importlib.reload(get_hooks)
assert get_hooks.EXEC == "python"
def test_hooks_payload(self):
hooks = hooks_payload["hooks"]
assert "slack_cli_hooks.hooks.get_manifest" in hooks["get-manifest"]
assert "slack_cli_hooks.hooks.start" in hooks["start"]
assert "slack_cli_hooks.hooks.check_update" in hooks["check-update"]
assert "slack_cli_hooks.hooks.doctor" in hooks["doctor"]
def test_hooks_payload_config(self):
config = hooks_payload["config"]
assert config["sdk-managed-connection-enabled"] is True
assert config["protocol-version"] == ["message-boundaries", "default"]
def test_hooks_watch_app(self):
config = hooks_payload["config"]
assert config["watch"] is not None
assert config["watch"]["app"] is not None
assert config["watch"]["app"]["filter-regex"] == "\\.py$"
assert config["watch"]["app"]["paths"] == ["."]
def test_hooks_watch_manifest(self):
config = hooks_payload["config"]
assert config["watch"] is not None
assert config["watch"]["manifest"] is not None
assert config["watch"]["manifest"]["paths"] == ["manifest.json"]
def test_hooks_runtime(self):
runtime = hooks_payload["runtime"]
assert runtime == "python"