Blame tests/test_pagure_flask.py

Pierre-Yves Chibon 17b6f6
# -*- coding: utf-8 -*-
Pierre-Yves Chibon 17b6f6
Pierre-Yves Chibon 17b6f6
"""
Pierre-Yves Chibon 17b6f6
 (c) 2017 - Copyright Red Hat Inc
Pierre-Yves Chibon 17b6f6
Pierre-Yves Chibon 17b6f6
 Authors:
Pierre-Yves Chibon 17b6f6
   Pierre-Yves Chibon <pingou@pingoured.fr></pingou@pingoured.fr>
Pierre-Yves Chibon 17b6f6
Pierre-Yves Chibon 17b6f6
"""
Pierre-Yves Chibon 17b6f6
Pierre-Yves Chibon 17b6f6
__requires__ = ['SQLAlchemy >= 0.8']
Pierre-Yves Chibon 17b6f6
import pkg_resources
Pierre-Yves Chibon 17b6f6
Pierre-Yves Chibon 17b6f6
import unittest
Pierre-Yves Chibon 17b6f6
import shutil
Pierre-Yves Chibon 17b6f6
import sys
Pierre-Yves Chibon 17b6f6
import os
Pierre-Yves Chibon 17b6f6
Pierre-Yves Chibon 17b6f6
import mock
Pierre-Yves Chibon 17b6f6
import pygit2
Pierre-Yves Chibon 17b6f6
import werkzeug
Pierre-Yves Chibon 17b6f6
Pierre-Yves Chibon 17b6f6
sys.path.insert(0, os.path.join(os.path.dirname(
Pierre-Yves Chibon 17b6f6
    os.path.abspath(__file__)), '..'))
Pierre-Yves Chibon 17b6f6
Pierre-Yves Chibon 17b6f6
import pagure.lib
Pierre-Yves Chibon 17b6f6
import pagure.lib.model
Pierre-Yves Chibon 17b6f6
import tests
Pierre-Yves Chibon 17b6f6
Pierre-Yves Chibon 17b6f6
class PagureGetRemoteRepoPath(tests.Modeltests):
Pierre-Yves Chibon 17b6f6
    """ Tests for pagure """
Pierre-Yves Chibon 17b6f6
Pierre-Yves Chibon 17b6f6
    def setUp(self):
Pierre-Yves Chibon 17b6f6
        """ Set up the environnment, ran before every tests. """
Pierre-Yves Chibon 17b6f6
        super(PagureGetRemoteRepoPath, self).setUp()
Pierre-Yves Chibon 17b6f6
Pierre-Yves Chibon 17b6f6
        pagure.APP.config['GIT_FOLDER'] = os.path.join(self.path, 'repos')
Pierre-Yves Chibon 17b6f6
        pagure.APP.config['REMOTE_GIT_FOLDER'] = os.path.join(
Pierre-Yves Chibon 17b6f6
            self.path, 'remotes')
Pierre-Yves Chibon 17b6f6
        tests.create_projects(self.session)
Pierre-Yves Chibon 17b6f6
        tests.create_projects_git(os.path.join(self.path, 'repos'), bare=True)
Pierre-Yves Chibon 17b6f6
        tests.add_content_git_repo(os.path.join(self.path, 'repos', 'test2.git'))
Pierre-Yves Chibon 17b6f6
Pierre-Yves Chibon 17b6f6
    @mock.patch(
Pierre-Yves Chibon 17b6f6
        'pagure.lib.repo.PagureRepo.pull',
Pierre-Yves Chibon 17b6f6
        mock.MagicMock(side_effect=pygit2.GitError))
Pierre-Yves Chibon 17b6f6
    def test_passing(self):
Pierre-Yves Chibon 17b6f6
        """ Test get_remote_repo_path in pagure. """
Pierre-Yves Chibon 17b6f6
        output = pagure.get_remote_repo_path(
Patrick Uiterwijk 7d2547
            os.path.join(self.path, 'repos', 'test2.git'), 'master',
Patrick Uiterwijk 7d2547
            ignore_non_exist=True)
Pierre-Yves Chibon 17b6f6
Pierre-Yves Chibon 17b6f6
        self.assertTrue(output.endswith('repos_test2.git_master'))
Pierre-Yves Chibon 17b6f6
Pierre-Yves Chibon 17b6f6
Pierre-Yves Chibon 17b6f6
if __name__ == '__main__':
Pierre-Yves Chibon 78e6f4
    unittest.main(verbosity=2)