Show More
@@ -16,4 +16,4 b'' | |||||
16 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
16 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 |
|
17 | |||
18 |
|
18 | |||
19 | from .app import create_app |
|
19 | from .app import create_app # noqa |
@@ -17,7 +17,6 b'' | |||||
17 |
|
17 | |||
18 | import re |
|
18 | import re | |
19 | import logging |
|
19 | import logging | |
20 | from wsgiref.util import FileWrapper |
|
|||
21 |
|
20 | |||
22 | from pyramid.config import Configurator |
|
21 | from pyramid.config import Configurator | |
23 | from pyramid.response import Response, FileIter |
|
22 | from pyramid.response import Response, FileIter |
@@ -35,7 +35,7 b' import mercurial.node' | |||||
35 | from vcsserver.lib.rc_json import json |
|
35 | from vcsserver.lib.rc_json import json | |
36 | from vcsserver import exceptions, subprocessio, settings |
|
36 | from vcsserver import exceptions, subprocessio, settings | |
37 | from vcsserver.str_utils import ascii_str, safe_str |
|
37 | from vcsserver.str_utils import ascii_str, safe_str | |
38 | from vcsserver.remote.git import Repository |
|
38 | from vcsserver.remote.git_remote import Repository | |
39 |
|
39 | |||
40 | log = logging.getLogger(__name__) |
|
40 | log = logging.getLogger(__name__) | |
41 |
|
41 |
@@ -40,20 +40,7 b' from vcsserver.lib.rc_json import json' | |||||
40 | from vcsserver.config.settings_maker import SettingsMaker |
|
40 | from vcsserver.config.settings_maker import SettingsMaker | |
41 | from vcsserver.str_utils import safe_int |
|
41 | from vcsserver.str_utils import safe_int | |
42 | from vcsserver.lib.statsd_client import StatsdClient |
|
42 | from vcsserver.lib.statsd_client import StatsdClient | |
43 |
from vcsserver.tweens.request_wrapper import |
|
43 | from vcsserver.tweens.request_wrapper import get_headers_call_context | |
44 |
|
||||
45 | log = logging.getLogger(__name__) |
|
|||
46 |
|
||||
47 | # due to Mercurial/glibc2.27 problems we need to detect if locale settings are |
|
|||
48 | # causing problems and "fix" it in case they do and fallback to LC_ALL = C |
|
|||
49 |
|
||||
50 | try: |
|
|||
51 | locale.setlocale(locale.LC_ALL, '') |
|
|||
52 | except locale.Error as e: |
|
|||
53 | log.error( |
|
|||
54 | 'LOCALE ERROR: failed to set LC_ALL, fallback to LC_ALL=C, org error: %s', e) |
|
|||
55 | os.environ['LC_ALL'] = 'C' |
|
|||
56 |
|
||||
57 |
|
44 | |||
58 | import vcsserver |
|
45 | import vcsserver | |
59 | from vcsserver import remote_wsgi, scm_app, settings, hgpatches |
|
46 | from vcsserver import remote_wsgi, scm_app, settings, hgpatches | |
@@ -68,7 +55,7 b' strict_vcs = True' | |||||
68 |
|
55 | |||
69 | git_import_err = None |
|
56 | git_import_err = None | |
70 | try: |
|
57 | try: | |
71 | from vcsserver.remote.git import GitFactory, GitRemote |
|
58 | from vcsserver.remote.git_remote import GitFactory, GitRemote | |
72 | except ImportError as e: |
|
59 | except ImportError as e: | |
73 | GitFactory = None |
|
60 | GitFactory = None | |
74 | GitRemote = None |
|
61 | GitRemote = None | |
@@ -79,7 +66,7 b' except ImportError as e:' | |||||
79 |
|
66 | |||
80 | hg_import_err = None |
|
67 | hg_import_err = None | |
81 | try: |
|
68 | try: | |
82 | from vcsserver.remote.hg import MercurialFactory, HgRemote |
|
69 | from vcsserver.remote.hg_remote import MercurialFactory, HgRemote | |
83 | except ImportError as e: |
|
70 | except ImportError as e: | |
84 | MercurialFactory = None |
|
71 | MercurialFactory = None | |
85 | HgRemote = None |
|
72 | HgRemote = None | |
@@ -90,7 +77,7 b' except ImportError as e:' | |||||
90 |
|
77 | |||
91 | svn_import_err = None |
|
78 | svn_import_err = None | |
92 | try: |
|
79 | try: | |
93 | from vcsserver.remote.svn import SubversionFactory, SvnRemote |
|
80 | from vcsserver.remote.svn_remote import SubversionFactory, SvnRemote | |
94 | except ImportError as e: |
|
81 | except ImportError as e: | |
95 | SubversionFactory = None |
|
82 | SubversionFactory = None | |
96 | SvnRemote = None |
|
83 | SvnRemote = None | |
@@ -98,6 +85,18 b' except ImportError as e:' | |||||
98 | if strict_vcs: |
|
85 | if strict_vcs: | |
99 | raise |
|
86 | raise | |
100 |
|
87 | |||
|
88 | log = logging.getLogger(__name__) | |||
|
89 | ||||
|
90 | # due to Mercurial/glibc2.27 problems we need to detect if locale settings are | |||
|
91 | # causing problems and "fix" it in case they do and fallback to LC_ALL = C | |||
|
92 | ||||
|
93 | try: | |||
|
94 | locale.setlocale(locale.LC_ALL, '') | |||
|
95 | except locale.Error as e: | |||
|
96 | log.error( | |||
|
97 | 'LOCALE ERROR: failed to set LC_ALL, fallback to LC_ALL=C, org error: %s', e) | |||
|
98 | os.environ['LC_ALL'] = 'C' | |||
|
99 | ||||
101 |
|
100 | |||
102 | def _is_request_chunked(environ): |
|
101 | def _is_request_chunked(environ): | |
103 | stream = environ.get('HTTP_TRANSFER_ENCODING', '') == 'chunked' |
|
102 | stream = environ.get('HTTP_TRANSFER_ENCODING', '') == 'chunked' | |
@@ -444,10 +443,7 b' class HTTPApplication(object):' | |||||
444 | method = method.split('stream:')[-1] |
|
443 | method = method.split('stream:')[-1] | |
445 | chunk_size = safe_int(payload.get('chunk_size')) or 4096 |
|
444 | chunk_size = safe_int(payload.get('chunk_size')) or 4096 | |
446 |
|
445 | |||
447 | try: |
|
|||
448 |
|
|
446 | resp = getattr(remote, method)(*args, **kwargs) | |
449 | except Exception as e: |
|
|||
450 | raise |
|
|||
451 |
|
447 | |||
452 | def get_chunked_data(method_resp): |
|
448 | def get_chunked_data(method_resp): | |
453 | stream = io.BytesIO(method_resp) |
|
449 | stream = io.BytesIO(method_resp) | |
@@ -694,7 +690,7 b' class ResponseFilter(object):' | |||||
694 |
|
690 | |||
695 |
|
691 | |||
696 | def sanitize_settings_and_apply_defaults(global_config, settings): |
|
692 | def sanitize_settings_and_apply_defaults(global_config, settings): | |
697 | global_settings_maker = SettingsMaker(global_config) |
|
693 | _global_settings_maker = SettingsMaker(global_config) | |
698 | settings_maker = SettingsMaker(settings) |
|
694 | settings_maker = SettingsMaker(settings) | |
699 |
|
695 | |||
700 | settings_maker.make_setting('logging.autoconfigure', False, parser='bool') |
|
696 | settings_maker.make_setting('logging.autoconfigure', False, parser='bool') | |
@@ -770,5 +766,3 b' def main(global_config, **settings):' | |||||
770 | total_time = time.time() - start_time |
|
766 | total_time = time.time() - start_time | |
771 | log.info('Pyramid app created and configured in %.2fs', total_time) |
|
767 | log.info('Pyramid app created and configured in %.2fs', total_time) | |
772 | return pyramid_app |
|
768 | return pyramid_app | |
773 |
|
||||
774 |
|
1 | NO CONTENT: file renamed from vcsserver/remote/git.py to vcsserver/remote/git_remote.py |
|
NO CONTENT: file renamed from vcsserver/remote/git.py to vcsserver/remote/git_remote.py |
1 | NO CONTENT: file renamed from vcsserver/remote/hg.py to vcsserver/remote/hg_remote.py |
|
NO CONTENT: file renamed from vcsserver/remote/hg.py to vcsserver/remote/hg_remote.py |
@@ -37,12 +37,20 b' import svn.fs # noqa' | |||||
37 | import svn.repos # noqa |
|
37 | import svn.repos # noqa | |
38 |
|
38 | |||
39 | from vcsserver import svn_diff, exceptions, subprocessio, settings |
|
39 | from vcsserver import svn_diff, exceptions, subprocessio, settings | |
40 | from vcsserver.base import RepoFactory, raise_from_original, ArchiveNode, store_archive_in_cache, BytesEnvelope, BinaryEnvelope |
|
40 | from vcsserver.base import ( | |
|
41 | RepoFactory, | |||
|
42 | raise_from_original, | |||
|
43 | ArchiveNode, | |||
|
44 | store_archive_in_cache, | |||
|
45 | BytesEnvelope, | |||
|
46 | BinaryEnvelope, | |||
|
47 | ) | |||
41 | from vcsserver.exceptions import NoContentException |
|
48 | from vcsserver.exceptions import NoContentException | |
42 | from vcsserver.str_utils import safe_str, safe_bytes |
|
49 | from vcsserver.str_utils import safe_str, safe_bytes | |
43 | from vcsserver.type_utils import assert_bytes |
|
50 | from vcsserver.type_utils import assert_bytes | |
44 | from vcsserver.vcs_base import RemoteBase |
|
51 | from vcsserver.vcs_base import RemoteBase | |
45 | from vcsserver.lib.svnremoterepo import svnremoterepo |
|
52 | from vcsserver.lib.svnremoterepo import svnremoterepo | |
|
53 | ||||
46 | log = logging.getLogger(__name__) |
|
54 | log = logging.getLogger(__name__) | |
47 |
|
55 | |||
48 |
|
56 |
@@ -21,7 +21,7 b' import pytest' | |||||
21 | import dulwich.errors |
|
21 | import dulwich.errors | |
22 | from mock import Mock, patch |
|
22 | from mock import Mock, patch | |
23 |
|
23 | |||
24 | from vcsserver.remote import git |
|
24 | from vcsserver.remote import git_remote | |
25 |
|
25 | |||
26 | SAMPLE_REFS = { |
|
26 | SAMPLE_REFS = { | |
27 | 'HEAD': 'fd627b9e0dd80b47be81af07c4a98518244ed2f7', |
|
27 | 'HEAD': 'fd627b9e0dd80b47be81af07c4a98518244ed2f7', | |
@@ -33,17 +33,17 b' SAMPLE_REFS = {' | |||||
33 |
|
33 | |||
34 |
|
34 | |||
35 | @pytest.fixture |
|
35 | @pytest.fixture | |
36 | def git_remote(): |
|
36 | def git_remote_fix(): | |
37 | """ |
|
37 | """ | |
38 | A GitRemote instance with a mock factory. |
|
38 | A GitRemote instance with a mock factory. | |
39 | """ |
|
39 | """ | |
40 | factory = Mock() |
|
40 | factory = Mock() | |
41 | remote = git.GitRemote(factory) |
|
41 | remote = git_remote.GitRemote(factory) | |
42 | return remote |
|
42 | return remote | |
43 |
|
43 | |||
44 |
|
44 | |||
45 | def test_discover_git_version(git_remote): |
|
45 | def test_discover_git_version(git_remote_fix): | |
46 | version = git_remote.discover_git_version() |
|
46 | version = git_remote_fix.discover_git_version() | |
47 | assert version |
|
47 | assert version | |
48 |
|
48 | |||
49 |
|
49 | |||
@@ -52,7 +52,7 b' class TestGitFetch(object):' | |||||
52 | self.mock_repo = Mock() |
|
52 | self.mock_repo = Mock() | |
53 | factory = Mock() |
|
53 | factory = Mock() | |
54 | factory.repo = Mock(return_value=self.mock_repo) |
|
54 | factory.repo = Mock(return_value=self.mock_repo) | |
55 | self.remote_git = git.GitRemote(factory) |
|
55 | self.remote_git = git_remote.GitRemote(factory) | |
56 |
|
56 | |||
57 | def test_fetches_all_when_no_commit_ids_specified(self): |
|
57 | def test_fetches_all_when_no_commit_ids_specified(self): | |
58 | def side_effect(determine_wants, *args, **kwargs): |
|
58 | def side_effect(determine_wants, *args, **kwargs): | |
@@ -85,14 +85,14 b' class TestGitFetch(object):' | |||||
85 |
|
85 | |||
86 | def test_get_remote_refs(self): |
|
86 | def test_get_remote_refs(self): | |
87 | factory = Mock() |
|
87 | factory = Mock() | |
88 | remote_git = git.GitRemote(factory) |
|
88 | remote_git = git_remote.GitRemote(factory) | |
89 | url = 'http://example.com/test/test.git' |
|
89 | url = 'https://example.com/test/test.git' | |
90 | sample_refs = { |
|
90 | sample_refs = { | |
91 | 'refs/tags/v0.1.8': '74ebce002c088b8a5ecf40073db09375515ecd68', |
|
91 | 'refs/tags/v0.1.8': '74ebce002c088b8a5ecf40073db09375515ecd68', | |
92 | 'refs/tags/v0.1.3': '5a3a8fb005554692b16e21dee62bf02667d8dc3e', |
|
92 | 'refs/tags/v0.1.3': '5a3a8fb005554692b16e21dee62bf02667d8dc3e', | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 | with patch('vcsserver.remote.git.Repo', create=False) as mock_repo: |
|
95 | with patch('vcsserver.remote.git_remote.Repo', create=False) as mock_repo: | |
96 | mock_repo().get_refs.return_value = sample_refs |
|
96 | mock_repo().get_refs.return_value = sample_refs | |
97 | remote_refs = remote_git.get_remote_refs(wire={}, url=url) |
|
97 | remote_refs = remote_git.get_remote_refs(wire={}, url=url) | |
98 | mock_repo().get_refs.assert_called_once_with() |
|
98 | mock_repo().get_refs.assert_called_once_with() | |
@@ -103,14 +103,14 b' class TestReraiseSafeExceptions(object):' | |||||
103 |
|
103 | |||
104 | def test_method_decorated_with_reraise_safe_exceptions(self): |
|
104 | def test_method_decorated_with_reraise_safe_exceptions(self): | |
105 | factory = Mock() |
|
105 | factory = Mock() | |
106 | git_remote = git.GitRemote(factory) |
|
106 | git_remote_instance = git_remote.GitRemote(factory) | |
107 |
|
107 | |||
108 | def fake_function(): |
|
108 | def fake_function(): | |
109 | return None |
|
109 | return None | |
110 |
|
110 | |||
111 | decorator = git.reraise_safe_exceptions(fake_function) |
|
111 | decorator = git_remote.reraise_safe_exceptions(fake_function) | |
112 |
|
112 | |||
113 | methods = inspect.getmembers(git_remote, predicate=inspect.ismethod) |
|
113 | methods = inspect.getmembers(git_remote_instance, predicate=inspect.ismethod) | |
114 | for method_name, method in methods: |
|
114 | for method_name, method in methods: | |
115 | if not method_name.startswith('_') and method_name not in ['vcsserver_invalidate_cache']: |
|
115 | if not method_name.startswith('_') and method_name not in ['vcsserver_invalidate_cache']: | |
116 | assert method.__func__.__code__ == decorator.__code__ |
|
116 | assert method.__func__.__code__ == decorator.__code__ | |
@@ -124,7 +124,7 b' class TestReraiseSafeExceptions(object):' | |||||
124 | (dulwich.errors.UnexpectedCommandError('test-cmd'), 'error'), |
|
124 | (dulwich.errors.UnexpectedCommandError('test-cmd'), 'error'), | |
125 | ]) |
|
125 | ]) | |
126 | def test_safe_exceptions_reraised(self, side_effect, expected_type): |
|
126 | def test_safe_exceptions_reraised(self, side_effect, expected_type): | |
127 | @git.reraise_safe_exceptions |
|
127 | @git_remote.reraise_safe_exceptions | |
128 | def fake_method(): |
|
128 | def fake_method(): | |
129 | raise side_effect |
|
129 | raise side_effect | |
130 |
|
130 | |||
@@ -137,9 +137,9 b' class TestReraiseSafeExceptions(object):' | |||||
137 | class TestDulwichRepoWrapper(object): |
|
137 | class TestDulwichRepoWrapper(object): | |
138 | def test_calls_close_on_delete(self): |
|
138 | def test_calls_close_on_delete(self): | |
139 | isdir_patcher = patch('dulwich.repo.os.path.isdir', return_value=True) |
|
139 | isdir_patcher = patch('dulwich.repo.os.path.isdir', return_value=True) | |
140 | with patch.object(git.Repo, 'close') as close_mock: |
|
140 | with patch.object(git_remote.Repo, 'close') as close_mock: | |
141 | with isdir_patcher: |
|
141 | with isdir_patcher: | |
142 | repo = git.Repo('/tmp/abcde') |
|
142 | repo = git_remote.Repo('/tmp/abcde') | |
143 | assert repo is not None |
|
143 | assert repo is not None | |
144 | repo.__del__() |
|
144 | repo.__del__() | |
145 | # can't use del repo as in python3 this isn't always calling .__del__() |
|
145 | # can't use del repo as in python3 this isn't always calling .__del__() | |
@@ -152,11 +152,11 b' class TestGitFactory(object):' | |||||
152 |
|
152 | |||
153 | with patch('vcsserver.lib.rc_cache.region_meta.dogpile_cache_regions') as mock: |
|
153 | with patch('vcsserver.lib.rc_cache.region_meta.dogpile_cache_regions') as mock: | |
154 | mock.side_effect = {'repo_objects': ''} |
|
154 | mock.side_effect = {'repo_objects': ''} | |
155 | factory = git.GitFactory() |
|
155 | factory = git_remote.GitFactory() | |
156 | wire = { |
|
156 | wire = { | |
157 | 'path': '/tmp/abcde' |
|
157 | 'path': '/tmp/abcde' | |
158 | } |
|
158 | } | |
159 | isdir_patcher = patch('dulwich.repo.os.path.isdir', return_value=True) |
|
159 | isdir_patcher = patch('dulwich.repo.os.path.isdir', return_value=True) | |
160 | with isdir_patcher: |
|
160 | with isdir_patcher: | |
161 | result = factory._create_repo(wire, True) |
|
161 | result = factory._create_repo(wire, True) | |
162 | assert isinstance(result, git.Repo) |
|
162 | assert isinstance(result, git_remote.Repo) |
@@ -24,19 +24,19 b' from mercurial.error import LookupError' | |||||
24 | from mock import Mock, patch |
|
24 | from mock import Mock, patch | |
25 |
|
25 | |||
26 | from vcsserver import exceptions, hgcompat |
|
26 | from vcsserver import exceptions, hgcompat | |
27 | from vcsserver.remote import hg |
|
27 | from vcsserver.remote import hg_remote | |
28 |
|
28 | |||
29 |
|
29 | |||
30 | class TestDiff(object): |
|
30 | class TestDiff(object): | |
31 | def test_raising_safe_exception_when_lookup_failed(self): |
|
31 | def test_raising_safe_exception_when_lookup_failed(self): | |
32 |
|
32 | |||
33 | factory = Mock() |
|
33 | factory = Mock() | |
34 | hg_remote = hg.HgRemote(factory) |
|
34 | hg_remote_instance = hg_remote.HgRemote(factory) | |
35 | with patch('mercurial.patch.diff') as diff_mock: |
|
35 | with patch('mercurial.patch.diff') as diff_mock: | |
36 | diff_mock.side_effect = LookupError(b'deadbeef', b'index', b'message') |
|
36 | diff_mock.side_effect = LookupError(b'deadbeef', b'index', b'message') | |
37 |
|
37 | |||
38 | with pytest.raises(Exception) as exc_info: |
|
38 | with pytest.raises(Exception) as exc_info: | |
39 | hg_remote.diff( |
|
39 | hg_remote_instance.diff( | |
40 | wire={}, commit_id_1='deadbeef', commit_id_2='deadbee1', |
|
40 | wire={}, commit_id_1='deadbeef', commit_id_2='deadbee1', | |
41 | file_filter=None, opt_git=True, opt_ignorews=True, |
|
41 | file_filter=None, opt_git=True, opt_ignorews=True, | |
42 | context=3) |
|
42 | context=3) | |
@@ -45,25 +45,27 b' class TestDiff(object):' | |||||
45 |
|
45 | |||
46 |
|
46 | |||
47 | class TestReraiseSafeExceptions(object): |
|
47 | class TestReraiseSafeExceptions(object): | |
|
48 | original_traceback = None | |||
|
49 | ||||
48 | def test_method_decorated_with_reraise_safe_exceptions(self): |
|
50 | def test_method_decorated_with_reraise_safe_exceptions(self): | |
49 | factory = Mock() |
|
51 | factory = Mock() | |
50 | hg_remote = hg.HgRemote(factory) |
|
52 | hg_remote_instance = hg_remote.HgRemote(factory) | |
51 | methods = inspect.getmembers(hg_remote, predicate=inspect.ismethod) |
|
53 | methods = inspect.getmembers(hg_remote_instance, predicate=inspect.ismethod) | |
52 | decorator = hg.reraise_safe_exceptions(None) |
|
54 | decorator = hg_remote.reraise_safe_exceptions(None) | |
53 | for method_name, method in methods: |
|
55 | for method_name, method in methods: | |
54 | if not method_name.startswith('_') and method_name not in ['vcsserver_invalidate_cache']: |
|
56 | if not method_name.startswith('_') and method_name not in ['vcsserver_invalidate_cache']: | |
55 | assert method.__func__.__code__ == decorator.__code__ |
|
57 | assert method.__func__.__code__ == decorator.__code__ | |
56 |
|
58 | |||
57 | @pytest.mark.parametrize('side_effect, expected_type', [ |
|
59 | @pytest.mark.parametrize('side_effect, expected_type', [ | |
58 | (hgcompat.Abort('failed-abort'), 'abort'), |
|
60 | (hgcompat.Abort(b'failed-abort'), 'abort'), | |
59 | (hgcompat.InterventionRequired('intervention-required'), 'abort'), |
|
61 | (hgcompat.InterventionRequired(b'intervention-required'), 'abort'), | |
60 | (hgcompat.RepoLookupError(), 'lookup'), |
|
62 | (hgcompat.RepoLookupError(), 'lookup'), | |
61 | (hgcompat.LookupError(b'deadbeef', b'index', b'message'), 'lookup'), |
|
63 | (hgcompat.LookupError(b'deadbeef', b'index', b'message'), 'lookup'), | |
62 | (hgcompat.RepoError(), 'error'), |
|
64 | (hgcompat.RepoError(), 'error'), | |
63 | (hgcompat.RequirementError(), 'requirement'), |
|
65 | (hgcompat.RequirementError(), 'requirement'), | |
64 | ]) |
|
66 | ]) | |
65 | def test_safe_exceptions_reraised(self, side_effect, expected_type): |
|
67 | def test_safe_exceptions_reraised(self, side_effect, expected_type): | |
66 | @hg.reraise_safe_exceptions |
|
68 | @hg_remote.reraise_safe_exceptions | |
67 | def fake_method(): |
|
69 | def fake_method(): | |
68 | raise side_effect |
|
70 | raise side_effect | |
69 |
|
71 | |||
@@ -73,14 +75,16 b' class TestReraiseSafeExceptions(object):' | |||||
73 | assert exc_info.value._vcs_kind == expected_type |
|
75 | assert exc_info.value._vcs_kind == expected_type | |
74 |
|
76 | |||
75 | def test_keeps_original_traceback(self): |
|
77 | def test_keeps_original_traceback(self): | |
76 | @hg.reraise_safe_exceptions |
|
78 | ||
|
79 | @hg_remote.reraise_safe_exceptions | |||
77 | def fake_method(): |
|
80 | def fake_method(): | |
78 | try: |
|
81 | try: | |
79 | raise hgcompat.Abort('test-abort') |
|
82 | raise hgcompat.Abort(b'test-abort') | |
80 | except: |
|
83 | except: | |
81 | self.original_traceback = traceback.format_tb(sys.exc_info()[2]) |
|
84 | self.original_traceback = traceback.format_tb(sys.exc_info()[2]) | |
82 | raise |
|
85 | raise | |
83 |
|
86 | |||
|
87 | new_traceback = None | |||
84 | try: |
|
88 | try: | |
85 | fake_method() |
|
89 | fake_method() | |
86 | except Exception: |
|
90 | except Exception: | |
@@ -89,8 +93,8 b' class TestReraiseSafeExceptions(object):' | |||||
89 | new_traceback_tail = new_traceback[-len(self.original_traceback):] |
|
93 | new_traceback_tail = new_traceback[-len(self.original_traceback):] | |
90 | assert new_traceback_tail == self.original_traceback |
|
94 | assert new_traceback_tail == self.original_traceback | |
91 |
|
95 | |||
92 | def test_maps_unknow_exceptions_to_unhandled(self): |
|
96 | def test_maps_unknown_exceptions_to_unhandled(self): | |
93 | @hg.reraise_safe_exceptions |
|
97 | @hg_remote.reraise_safe_exceptions | |
94 | def stub_method(): |
|
98 | def stub_method(): | |
95 | raise ValueError('stub') |
|
99 | raise ValueError('stub') | |
96 |
|
100 | |||
@@ -99,7 +103,7 b' class TestReraiseSafeExceptions(object):' | |||||
99 | assert exc_info.value._vcs_kind == 'unhandled' |
|
103 | assert exc_info.value._vcs_kind == 'unhandled' | |
100 |
|
104 | |||
101 | def test_does_not_map_known_exceptions(self): |
|
105 | def test_does_not_map_known_exceptions(self): | |
102 | @hg.reraise_safe_exceptions |
|
106 | @hg_remote.reraise_safe_exceptions | |
103 | def stub_method(): |
|
107 | def stub_method(): | |
104 | raise exceptions.LookupException()('stub') |
|
108 | raise exceptions.LookupException()('stub') | |
105 |
|
109 |
@@ -46,11 +46,11 b" INVALID_CERTIFICATE_STDERR = '\\n'.join([" | |||||
46 | @pytest.mark.xfail(sys.platform == "cygwin", |
|
46 | @pytest.mark.xfail(sys.platform == "cygwin", | |
47 | reason="SVN not packaged for Cygwin") |
|
47 | reason="SVN not packaged for Cygwin") | |
48 | def test_import_remote_repository_certificate_error(stderr, expected_reason): |
|
48 | def test_import_remote_repository_certificate_error(stderr, expected_reason): | |
49 | from vcsserver.remote import svn |
|
49 | from vcsserver.remote import svn_remote | |
50 | factory = mock.Mock() |
|
50 | factory = mock.Mock() | |
51 | factory.repo = mock.Mock(return_value=mock.Mock()) |
|
51 | factory.repo = mock.Mock(return_value=mock.Mock()) | |
52 |
|
52 | |||
53 | remote = svn.SvnRemote(factory) |
|
53 | remote = svn_remote.SvnRemote(factory) | |
54 | remote.is_path_valid_repository = lambda wire, path: True |
|
54 | remote.is_path_valid_repository = lambda wire, path: True | |
55 |
|
55 | |||
56 | with mock.patch('subprocess.Popen', |
|
56 | with mock.patch('subprocess.Popen', | |
@@ -64,7 +64,7 b' def test_import_remote_repository_certif' | |||||
64 |
|
64 | |||
65 |
|
65 | |||
66 | def test_svn_libraries_can_be_imported(): |
|
66 | def test_svn_libraries_can_be_imported(): | |
67 | import svn.client |
|
67 | import svn.client # noqa | |
68 | assert svn.client is not None |
|
68 | assert svn.client is not None | |
69 |
|
69 | |||
70 |
|
70 | |||
@@ -76,12 +76,12 b' def test_svn_libraries_can_be_imported()' | |||||
76 | ('http://', ('', '', 'http://')), |
|
76 | ('http://', ('', '', 'http://')), | |
77 | ]) |
|
77 | ]) | |
78 | def test_username_password_extraction_from_url(example_url, parts): |
|
78 | def test_username_password_extraction_from_url(example_url, parts): | |
79 | from vcsserver.remote import svn |
|
79 | from vcsserver.remote import svn_remote | |
80 |
|
80 | |||
81 | factory = mock.Mock() |
|
81 | factory = mock.Mock() | |
82 | factory.repo = mock.Mock(return_value=mock.Mock()) |
|
82 | factory.repo = mock.Mock(return_value=mock.Mock()) | |
83 |
|
83 | |||
84 | remote = svn.SvnRemote(factory) |
|
84 | remote = svn_remote.SvnRemote(factory) | |
85 | remote.is_path_valid_repository = lambda wire, path: True |
|
85 | remote.is_path_valid_repository = lambda wire, path: True | |
86 |
|
86 | |||
87 | assert remote.get_url_and_credentials(example_url) == parts |
|
87 | assert remote.get_url_and_credentials(example_url) == parts | |
@@ -93,11 +93,11 b' def test_username_password_extraction_fr' | |||||
93 | b'https://marcink:qweqwe@svn.code.sf.net/p/svnbook/source/trunk/', |
|
93 | b'https://marcink:qweqwe@svn.code.sf.net/p/svnbook/source/trunk/', | |
94 | ]) |
|
94 | ]) | |
95 | def test_check_url(call_url): |
|
95 | def test_check_url(call_url): | |
96 | from vcsserver.remote import svn |
|
96 | from vcsserver.remote import svn_remote | |
97 | factory = mock.Mock() |
|
97 | factory = mock.Mock() | |
98 | factory.repo = mock.Mock(return_value=mock.Mock()) |
|
98 | factory.repo = mock.Mock(return_value=mock.Mock()) | |
99 |
|
99 | |||
100 | remote = svn.SvnRemote(factory) |
|
100 | remote = svn_remote.SvnRemote(factory) | |
101 | remote.is_path_valid_repository = lambda wire, path: True |
|
101 | remote.is_path_valid_repository = lambda wire, path: True | |
102 | assert remote.check_url(call_url, {'dummy': 'config'}) |
|
102 | assert remote.check_url(call_url, {'dummy': 'config'}) | |
103 |
|
103 |
@@ -15,13 +15,13 b'' | |||||
15 | # along with this program; if not, write to the Free Software Foundation, |
|
15 | # along with this program; if not, write to the Free Software Foundation, | |
16 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
16 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | import base64 |
|
17 | import base64 | |
|
18 | import logging | |||
18 | import time |
|
19 | import time | |
19 | import logging |
|
|||
20 |
|
20 | |||
21 | import msgpack |
|
21 | import msgpack | |
22 |
|
22 | |||
23 | import vcsserver |
|
23 | import vcsserver | |
24 |
from vcsserver.str_utils import safe_str |
|
24 | from vcsserver.str_utils import safe_str | |
25 |
|
25 | |||
26 | log = logging.getLogger(__name__) |
|
26 | log = logging.getLogger(__name__) | |
27 |
|
27 |
General Comments 0
You need to be logged in to leave comments.
Login now