-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathcheck_test.py
35 lines (24 loc) · 1.12 KB
/
check_test.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
import unittest
from unittest import mock
import restic.errors
from restic.internal import check
class CheckTest(unittest.TestCase):
@mock.patch.object(check.command_executor, 'execute')
def test_check_simple(self, mock_execute):
restic.check()
mock_execute.assert_called_with(['restic', '--json', 'check'])
@mock.patch.object(check.command_executor, 'execute')
def test_check_and_read_data(self, mock_execute):
restic.check(read_data=True)
mock_execute.assert_called_with(
['restic', '--json', 'check', '--read-data'])
@mock.patch.object(check.command_executor, 'execute')
def test_check_and_read_data_subset(self, mock_execute):
restic.check(read_data_subset='10%')
mock_execute.assert_called_with(
['restic', '--json', 'check', '--read-data-subset', '10%'])
@mock.patch.object(check.command_executor, 'execute')
def test_check_returns_none_on_restic_failure(self, mock_execute):
mock_execute.side_effect = restic.errors.ResticFailedError(
'dummy restic failure')
self.assertIsNone(restic.check())