def test_snapshot_replace(self, mock_swallow, mock_call, mock_stashbuffer, mock_checkoutput): # given mock_checkoutput.side_effect = [ 'status\noutput\n', 'stash@{0}: WIP on master: 8a3a15e edit readme\nstash@{1}: On master: edit readme\n' ] # when snapshot.snapshot('edit readme', replace=True) # then mock_checkoutput.assert_has_calls( [mock.call('git status --porcelain'), mock.call('git stash list')]) mock_stashbuffer.assert_called_once() mock_call.assert_has_calls([ mock.call('git stash drop --quiet stash@{1}'.split()), mock.call([ 'git', 'stash', 'push', '--include-untracked', '--message', 'edit readme' ]) ]) mock_swallow.assert_called_once_with( 'git stash apply --quiet --index'.split())
def test_snapshot_noChangesToSnapshot(self, mock_info, mock_checkoutput): # when quiet = False snapshot.snapshot(quiet=quiet) # then mock_checkoutput.assert_called_once_with('git status --porcelain'.split()) mock_info.assert_called_once_with('No local changes to save. No snapshot created.', quiet)
def test_snapshot_noChangesToSnapshot(self, mock_info, mock_checkoutput): # when quiet = False snapshot.snapshot(quiet=quiet) # then mock_checkoutput.assert_called_once_with('git status --porcelain') mock_info.assert_called_once_with( 'No local changes to save. No snapshot created.', quiet)
def test_snapshot_noMessage(self, mock_swallow, mock_call, mock_stashbuffer, mock_checkoutput): # when snapshot.snapshot() # then mock_checkoutput.assert_called_once_with('git status --porcelain'.split()) mock_stashbuffer.assert_called_once() mock_call.assert_called_once_with('git stash push --include-untracked --quiet'.split()) mock_swallow.assert_called_once_with('git stash apply --quiet --index'.split())
def test_snapshot_withMessage(self, mock_swallow, mock_call, mock_stashbuffer, mock_checkoutput): # when message = 'the message' snapshot.snapshot(message) # then mock_checkoutput.assert_called_once_with('git status --porcelain'.split()) mock_stashbuffer.assert_called_once() mock_call.assert_called_once_with(['git', 'stash', 'push', '--include-untracked', '--quiet', '--message', message]) mock_swallow.assert_called_once_with('git stash apply --quiet --index'.split())
def test_snapshot_withFiles(self, mock_swallow, mock_call, mock_stashbuffer, mock_checkoutput): # when message = None files = ['file1', 'file2'] snapshot.snapshot(message, files=files) # then mock_checkoutput.assert_called_once_with('git status --porcelain'.split()) mock_stashbuffer.assert_called_once() mock_call.assert_called_once_with(['git', 'stash', 'push', '--include-untracked', '--quiet', '--'] + files) mock_swallow.assert_called_once_with('git stash apply --quiet --index'.split())
def test_snapshot_quiet(self, mock_swallow, mock_call, mock_stashbuffer, mock_checkoutput): # when snapshot.snapshot(quiet=True) # then mock_checkoutput.assert_called_once_with('git status --porcelain') mock_stashbuffer.assert_called_once() mock_call.assert_called_once_with( 'git stash push --include-untracked --quiet'.split()) mock_swallow.assert_called_once_with( 'git stash apply --quiet --index'.split())
def test_snapshot_withFiles(self, mock_swallow, mock_call, mock_stashbuffer, mock_checkoutput): # when message = None files = ['file1', 'file2'] snapshot.snapshot(message, files=files) # then mock_checkoutput.assert_called_once_with('git status --porcelain') mock_stashbuffer.assert_called_once() mock_call.assert_called_once_with( ['git', 'stash', 'push', '--include-untracked', '--'] + files) mock_swallow.assert_called_once_with( 'git stash apply --quiet --index'.split())
def test_snapshot_withMessage(self, mock_swallow, mock_call, mock_stashbuffer, mock_checkoutput): # when message = 'the message' snapshot.snapshot(message) # then mock_checkoutput.assert_called_once_with('git status --porcelain') mock_stashbuffer.assert_called_once() mock_call.assert_called_once_with([ 'git', 'stash', 'push', '--include-untracked', '--message', message ]) mock_swallow.assert_called_once_with( 'git stash apply --quiet --index'.split())