def _do_on_path(self, cb, path, revision=HEAD): if not path: raise FileNotFoundError(path, revision) try: normpath = self.normalize_path(path) # SVN expects to have URLs escaped. Take care to only # escape the path part of the URL. if self.client.is_url(normpath): pathtuple = urlsplit(normpath) path = pathtuple[2] if isinstance(path, six.text_type): path = path.encode('utf-8', 'ignore') normpath = urlunsplit((pathtuple[0], pathtuple[1], quote(path), '', '')) normrev = self._normalize_revision(revision) return cb(normpath, normrev) except ClientError as e: exc = force_text(e) if 'File not found' in exc or 'path not found' in exc: raise FileNotFoundError(path, revision, detail=exc) elif 'callback_ssl_server_trust_prompt required' in exc: raise SCMError( _('HTTPS certificate not accepted. Please ensure that ' 'the proper certificate exists in %s ' 'for the user that reviewboard is running as.') % os.path.join(self.config_dir, 'auth')) else: raise SVNTool.normalize_error(e)
def _do_on_path(self, cb, path, revision=HEAD): if not path: raise FileNotFoundError(path, revision) try: normpath = self.normalize_path(path) # SVN expects to have URLs escaped. Take care to only # escape the path part of the URL. if self.client.is_url(normpath): pathtuple = urlsplit(normpath) path = pathtuple[2] if isinstance(path, six.text_type): path = path.encode("utf-8", "ignore") normpath = urlunsplit((pathtuple[0], pathtuple[1], quote(path), "", "")) normrev = self._normalize_revision(revision) return cb(normpath, normrev) except ClientError as e: exc = bytes(e).decode("utf-8") if "File not found" in exc or "path not found" in exc: raise FileNotFoundError(path, revision, detail=exc) elif "callback_ssl_server_trust_prompt required" in exc: raise SCMError( _( "HTTPS certificate not accepted. Please ensure that " "the proper certificate exists in %s " "for the user that reviewboard is running as." ) % os.path.join(self.config_dir, "auth") ) else: raise SVNTool.normalize_error(e)
def repository_info(self): """Metadata about the repository. This is a dictionary containing the following keys: ``uuid`` (:py:class:`unicode`): The UUID of the repository. ``root_url`` (:py:class:`unicode`): The root URL of the configured repository. ``url`` (:py:class:`unicoe`): The full URL of the configured repository. """ try: base = os.path.basename(self.repopath) info = self.client.info(self.repopath, 'HEAD')[base] except SubversionException as e: raise SVNTool.normalize_error(e) return { 'uuid': force_text(info.repos_uuid), 'root_url': force_text(info.repos_root_url), 'url': force_text(info.url), }
def test_fields(self): """Testing SVNTool authentication form fields""" form = SVNTool.create_auth_form() self.assertEqual(list(form.fields), ['username', 'password']) self.assertEqual(form['username'].help_text, '') self.assertEqual(form['username'].label, 'Username') self.assertEqual(form['password'].help_text, '') self.assertEqual(form['password'].label, 'Password')
def test_load(self): """Tetting SVNTool authentication form load""" repository = self.create_repository(tool_name='Subversion', username='******', password='******') form = SVNTool.create_auth_form(repository=repository) form.load() self.assertEqual(form['username'].value(), 'test-user') self.assertEqual(form['password'].value(), 'test-pass')
def test_fields(self): """Testing SVNTool repository form fields""" form = SVNTool.create_repository_form() self.assertEqual(list(form.fields), ['path', 'mirror_path']) self.assertEqual(form['path'].help_text, 'The path to the repository. This will generally be ' 'the URL you would use to check out the repository.') self.assertEqual(form['path'].label, 'Path') self.assertEqual(form['mirror_path'].help_text, '') self.assertEqual(form['mirror_path'].label, 'Mirror Path')
def test_load(self): """Tetting SVNTool repository form load""" repository = self.create_repository( tool_name='Subversion', path='https://svn.example.com/', mirror_path='https://svn.mirror.example.com') form = SVNTool.create_repository_form(repository=repository) form.load() self.assertEqual(form['path'].value(), 'https://svn.example.com/') self.assertEqual(form['mirror_path'].value(), 'https://svn.mirror.example.com')
def repository_info(self): """Returns metadata about the repository: * UUID * Root URL * URL """ try: info = self.client.info2(self.repopath, recurse=False) except ClientError as e: raise SVNTool.normalize_error(e) return {"uuid": info[0][1].repos_UUID, "root_url": info[0][1].repos_root_URL, "url": info[0][1].URL}
def test_save(self): """Tetting SVNTool authentication form save""" repository = self.create_repository(tool_name='Subversion') form = SVNTool.create_auth_form(repository=repository, data={ 'username': '******', 'password': '******', }) self.assertTrue(form.is_valid()) form.save() self.assertEqual(repository.username, 'test-user') self.assertEqual(repository.password, 'test-pass')
def repository_info(self): """Returns metadata about the repository: * UUID * Root URL * URL """ try: base = os.path.basename(self.repopath) info = self.client.info(self.repopath, "HEAD")[base] except SubversionException as e: raise SVNTool.normalize_error(e) return {"uuid": info.repos_uuid, "root_url": info.repos_root_url, "url": info.url}
def test_save(self): """Tetting SVNTool repository form save""" repository = self.create_repository(tool_name='Subversion') form = SVNTool.create_repository_form( repository=repository, data={ 'path': 'https://svn.example.com/', 'mirror_path': 'https://svn.mirror.example.com', }) self.assertTrue(form.is_valid()) form.save() self.assertEqual(repository.path, 'https://svn.example.com/') self.assertEqual(repository.mirror_path, 'https://svn.mirror.example.com')
def repository_info(self): """Returns metadata about the repository: * UUID * Root URL * URL """ try: info = self.client.info2(self.repopath, recurse=False) except ClientError as e: raise SVNTool.normalize_error(e) return { 'uuid': info[0][1].repos_UUID, 'root_url': info[0][1].repos_root_URL, 'url': info[0][1].URL }
def repository_info(self): """Returns metadata about the repository: * UUID * Root URL * URL """ try: base = os.path.basename(self.repopath) info = self.client.info(self.repopath, 'HEAD')[base] except SubversionException as e: raise SVNTool.normalize_error(e) return { 'uuid': info.repos_uuid, 'root_url': info.repos_root_url, 'url': info.url }
def _do_on_path(self, cb, path, revision=HEAD): if not path: raise FileNotFoundError(path, revision) try: normpath = self.normalize_path(path) normrev = self._normalize_revision(revision) return cb(normpath, normrev) except ClientError as e: exc = force_text(e) if 'File not found' in exc or 'path not found' in exc: raise FileNotFoundError(path, revision, detail=exc) elif 'callback_ssl_server_trust_prompt required' in exc: raise SCMError( _('HTTPS certificate not accepted. Please ensure that ' 'the proper certificate exists in %s ' 'for the user that reviewboard is running as.') % os.path.join(self.config_dir, 'auth')) else: raise SVNTool.normalize_error(e)
def repository_info(self): """Metadata about the repository. This is a dictionary containing the following keys: ``uuid`` (:py:class:`unicode`): The UUID of the repository. ``root_url`` (:py:class:`unicode`): The root URL of the configured repository. ``url`` (:py:class:`unicoe`): The full URL of the configured repository. """ try: info = self.client.info2(self.repopath, recurse=False) except ClientError as e: raise SVNTool.normalize_error(e) return { 'uuid': info[0][1].repos_UUID, 'root_url': info[0][1].repos_root_URL, 'url': info[0][1].URL }