-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import json | ||
|
||
from restic.internal import command_executor | ||
|
||
|
||
def run(restic_base_command, group_by=None): | ||
cmd = restic_base_command + ['snapshots'] | ||
|
||
if group_by: | ||
cmd.extend(['--group-by', group_by]) | ||
|
||
return json.loads(command_executor.execute(cmd)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import unittest | ||
from unittest import mock | ||
|
||
import restic | ||
from restic.internal import snapshots | ||
|
||
# Ignore suggestions to turn methods into functions. | ||
# pylint: disable=R0201 | ||
|
||
|
||
class SelfUpdateTest(unittest.TestCase): | ||
|
||
@mock.patch.object(snapshots.command_executor, 'execute') | ||
def test_snapshots_simple(self, mock_execute): | ||
mock_execute.return_value = '{}' | ||
|
||
restic.snapshots() | ||
|
||
mock_execute.assert_called_with(['restic', '--json', 'snapshots']) | ||
|
||
@mock.patch.object(snapshots.command_executor, 'execute') | ||
def test_snapshots_group_by_host(self, mock_execute): | ||
mock_execute.return_value = '{}' | ||
|
||
restic.snapshots(group_by='host') | ||
|
||
mock_execute.assert_called_with( | ||
['restic', '--json', 'snapshots', '--group-by', 'host']) |