Ejemplo n.º 1
0
def git_remote():
    """
    A GitRemote instance with a mock factory.
    """
    factory = Mock()
    remote = git.GitRemote(factory)
    return remote
Ejemplo n.º 2
0
    def test_method_decorated_with_reraise_safe_exceptions(self):
        factory = Mock()
        git_remote = git.GitRemote(factory)

        def fake_function():
            return None

        decorator = git.reraise_safe_exceptions(fake_function)

        methods = inspect.getmembers(git_remote, predicate=inspect.ismethod)
        for method_name, method in methods:
            if not method_name.startswith('_'):
                assert method.im_func.__code__ == decorator.__code__
Ejemplo n.º 3
0
    def test_get_remote_refs(self):
        factory = Mock()
        remote_git = git.GitRemote(factory)
        url = 'http://example.com/test/test.git'
        sample_refs = {
            'refs/tags/v0.1.8': '74ebce002c088b8a5ecf40073db09375515ecd68',
            'refs/tags/v0.1.3': '5a3a8fb005554692b16e21dee62bf02667d8dc3e',
        }

        with patch('vcsserver.git.Repo', create=False) as mock_repo:
            mock_repo().get_refs.return_value = sample_refs
            remote_refs = remote_git.get_remote_refs(wire=None, url=url)
            mock_repo().get_refs.assert_called_once_with()
            assert remote_refs == sample_refs
Ejemplo n.º 4
0
 def setup(self):
     self.mock_repo = Mock()
     factory = Mock()
     factory.repo = Mock(return_value=self.mock_repo)
     self.remote_git = git.GitRemote(factory)