def test_repo_diffs_err(mock_repo): with mock.patch('compose.config.config.get_default_config_files'): with mock.patch('subprocess.call'): with mock.patch('dip.settings.indir'): mock_repo.remote.side_effect = \ git.exc.GitCommandError('test', 'test') repo = settings.Repo('.', 'origin', 'master') with pytest.raises(errors.GitFetchError): assert any(repo.diffs())
def test_repo_diffs(mock_call, mock_compose, mock_repo): with mock.patch('dip.settings.indir'): mock_repo.remote.return_value.name = 'origin' mock_compose.return_value = ['/path/to/docker-compose.yml'] mock_call.return_value = 1 repo = settings.Repo('.', 'origin', 'master') ret = any(repo.diffs()) mock_repo.remote.return_value.fetch.assert_called_once_with() mock_call.assert_called_once_with([ 'git', 'diff', '--exit-code', 'origin/master:path/to/docker-compose.yml', '/path/to/docker-compose.yml' ]) assert ret is True
def test_repo_repr(): repo = settings.Repo('.') assert repr(repo) == "Repo({})".format(os.path.abspath('.'))
def test_repo_str(): repo = settings.Repo('.') assert str(repo) == os.path.abspath('.')
def test_repo_init(): with mock.patch('git.Repo'): repo = settings.Repo('./fizz/buzz') assert repo.path == os.path.abspath('./fizz/buzz')
def test_repo_pull(mock_call): with mock.patch('dip.settings.indir'): repo = settings.Repo('.', 'origin', 'master') repo.pull() mock_call.assert_called_once_with(['git', 'pull', 'origin', 'master'])
def test_repo_sleeptime(): repo = settings.Repo('.', 'origin') assert repo.sleeptime == 0
def test_repo_sleep(mock_sleep): repo = settings.Repo('.', 'origin', sleep=5) repo.sleep() mock_sleep.assert_called_once_with(5)
def test_repo_branch_active(mock_branch): mock_branch.name = 'branch' repo = settings.Repo('.', 'origin') ret = repo.branch assert ret == 'branch'
def test_repo_branch(): repo = settings.Repo('.', 'origin', 'branch') ret = repo.branch assert ret == 'branch'
def test_repo_remote_none(mock_repo): repo = settings.Repo('.') assert repo.remote mock_repo.remote.assert_called_once_with(None)
def test_repo_remote(mock_repo): repo = settings.Repo('.', 'origin', 'master', 10) assert repo.remote mock_repo.remote.assert_called_once_with('origin')
def test_repo_iter(args, expected): with mock.patch('git.Repo'): repo = settings.Repo(*args) assert dict(repo) == expected