Esempio n. 1
0
    def test_update_files_invalid_repo(self, mock_clone,
                                       mock_is_fetch_required, mock_fetch,
                                       mock_update):
        """Verify update_files throws exception on invalid repo when not forced"""
        source = Source('git', 'repo', 'name', rev='rev', link='link')

        with pytest.raises(Exception):
            source.update_files()

        mock_clone.assert_not_called()
        mock_is_fetch_required.assert_not_called()
        mock_fetch.assert_not_called()
        mock_update.assert_not_called()
Esempio n. 2
0
    def test_update_files_rebuild_git(
        self, mock_clone, mock_rebuild, mock_is_fetch_required, mock_fetch, mock_update
    ):
        """Verify update_files rebuilds when invalid repo and force is passed"""
        source = Source(type='git', repo='repo', name='name', rev='rev', link='link')
        source.update_files(force=True)

        mock_clone.assert_not_called()
        mock_rebuild.assert_called_once_with('git', 'repo')
        mock_is_fetch_required.assert_not_called()
        mock_fetch.assert_called_once_with('git', 'repo', 'name', rev='rev')
        mock_update.assert_called_once_with(
            'git', 'repo', 'name', clean=True, fetch=True, rev='rev'
        )
Esempio n. 3
0
    def test_update_files(
        self, mock_clone, mock_is_fetch_required, mock_fetch, mock_update
    ):
        """Verify update_files when path does not exist"""
        source = Source(type='git', repo='repo', name='name', rev='rev', link='link')
        source.update_files()

        mock_clone.assert_called_once_with(
            'git', 'repo', 'name', rev='rev', sparse_paths=[]
        )
        mock_is_fetch_required.assert_called_once_with('git', 'rev')
        mock_fetch.assert_called_once_with('git', 'repo', 'name', rev='rev')
        mock_update.assert_called_once_with(
            'git', 'repo', 'name', clean=True, fetch=False, rev='rev'
        )