-
Notifications
You must be signed in to change notification settings - Fork 30
/
test_startup_items.py
95 lines (79 loc) · 3.02 KB
/
test_startup_items.py
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from mock import patch
import startup_items
import config
@patch('startup_items.backup_system_daemons_agents')
@patch('startup_items.backup_system_launch_agents')
@patch('startup_items.backup_user_launch_agents')
def test_backup(user_agents_mock, system_agents_mock, system_daemons_mock):
startup_items.backup()
user_agents_mock.assert_called_once()
system_agents_mock.assert_called_once()
system_daemons_mock.assert_called_once()
@patch('startup_items.restore_system_daemons_agents')
@patch('startup_items.restore_system_launch_agents')
@patch('startup_items.restore_user_launch_agents')
def test_restore(user_agents_mock, system_agents_mock, system_daemons_mock):
startup_items.restore()
user_agents_mock.assert_called_once()
system_agents_mock.assert_called_once()
system_daemons_mock.assert_called_once()
@patch('startup_items.copy_dir')
def test_backup_user_launch_agents(copy_mock):
source = config.get_user_launch_agents_dir()
dest = config.get_user_launch_agents_backup_dir()
startup_items.backup_user_launch_agents()
copy_mock.assert_called_with(
source, dest
)
@patch('startup_items.copy_dir')
def test_backup_system_launch_agents(copy_mock):
source = config.get_system_launch_agents_dir()
dest = config.get_system_launch_agents_backup_dir()
startup_items.backup_system_launch_agents()
copy_mock.assert_called_with(
source, dest
)
@patch('startup_items.copy_dir')
def test_backup_system_daemons_agents(copy_mock):
source = config.get_system_launch_daemons_dir()
dest = config.get_system_launch_daemons_backup_dir()
startup_items.backup_system_daemons_agents()
copy_mock.assert_called_with(
source, dest
)
@patch('startup_items.ensure_dir_owned_by_user')
@patch('startup_items.copy_dir')
def test_restore_user_launch_agents(copy_mock, owned_mock):
source = config.get_user_launch_agents_backup_dir()
dest = config.get_user_launch_agents_dir()
startup_items.restore_user_launch_agents()
copy_mock.assert_called_with(
source, dest, with_sudo=True
)
owned_mock.assert_called_with(
dest, config.get_user()
)
@patch('startup_items.ensure_dir_owned_by_user')
@patch('startup_items.copy_dir')
def test_restore_system_launch_agents(copy_mock, owned_mock):
source = config.get_system_launch_agents_backup_dir()
dest = config.get_system_launch_agents_dir()
startup_items.restore_system_launch_agents()
copy_mock.assert_called_with(
source, dest, with_sudo=True
)
owned_mock.assert_called_with(
dest, 'root:wheel', '644'
)
@patch('startup_items.ensure_dir_owned_by_user')
@patch('startup_items.copy_dir')
def test_restore_system_daemons_agents(copy_mock, owned_mock):
source = config.get_system_launch_daemons_backup_dir()
dest = config.get_system_launch_daemons_dir()
startup_items.restore_system_daemons_agents()
copy_mock.assert_called_with(
source, dest, with_sudo=True
)
owned_mock.assert_called_with(
dest, 'root:wheel', '644'
)