forked from clintmod/macprefs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_shared_file_lists.py
32 lines (25 loc) · 971 Bytes
/
test_shared_file_lists.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
from mock import patch
import shared_file_lists
import config
@patch('shared_file_lists.copy_dir')
def test_backup_works(copy_dir_mock):
shared_file_lists.backup()
copy_dir_mock.assert_called_with(
config.get_shared_file_lists_dir(),
config.get_shared_file_lists_backup_dir()
)
@patch('shared_file_lists.exists')
@patch('shared_file_lists.copy_dir')
def test_backup_warns_if_not_exists(copy_dir_mock, exists_mock):
exists_mock.return_value = False
shared_file_lists.backup()
copy_dir_mock.assert_not_called()
@patch('shared_file_lists.ensure_dir_owned_by_user')
@patch('shared_file_lists.copy_dir')
def test_restore_works(copy_dir_mock, owned_mock):
shared_file_lists.restore()
copy_dir_mock.assert_called_with(
config.get_shared_file_lists_backup_dir(),
config.get_shared_file_lists_dir(), with_sudo=True
)
owned_mock.assert_called_with(config.get_shared_file_lists_dir(), config.get_user())