Example #1
0
    def test_exceptions_get_raised(self, monkeypatch):
        mock_sp_call = mock.Mock(return_value=7)
        monkeypatch.setattr(utils.subprocess, 'call', mock_sp_call)
        path = 'foo/bar/baz'
        args = ['par2', 'c', '-r5', 'baz.par2', path]

        with pytest.raises(exceptions.ParchiveError) as e:
            utils.create_parity_files(path)

            assert e.value == '{0} failed with code {1}'.format(' '.join(args), 7)

            with open(os.devnull, 'wb') as DEVNULL:
                mock_sp_call.assert_called_once_with(args, stdout=DEVNULL, stderr=DEVNULL)
Example #2
0
    def test_skip_empty_files(self, monkeypatch):
        mock_stat = mock.Mock(return_value=mock.Mock(st_size=0))
        mock_sp_call = mock.Mock()
        monkeypatch.setattr(os, 'stat', mock_stat)
        monkeypatch.setattr(utils.subprocess, 'call', mock_sp_call)
        path = 'foo/bar/baz'

        paths = utils.create_parity_files(path)
        assert paths == []
        assert not mock_sp_call.called