Ejemplo n.º 1
0
 def __init__(self,
              package: Package,
              format_desc: Optional[Callable[..., Any]] = None):
     super().__init__(package)
     try:
         utils.ensure_valid_url(self.repo_url)
     except Exception:
         raise RequirementNotFound(f"{self.repo_url} is not a valid url!",
                                   package=self.package)
     else:
         self._meta: dict = utils.get_package_meta(str(self.package),
                                                   self.repo_url)
         self.format_desc = format_desc or (lambda n: n)
Ejemplo n.º 2
0
 def __init__(self,
              package: Package,
              format_desc: Optional[Callable[..., Any]] = None):
     super().__init__(package)
     self.log.debug(
         f'VCS package!, {self.package.revision}@{self.package.vcs}@{self.package.full_name}'
     )
     self._repo: Optional[Repo] = None
     try:
         utils.ensure_valid_url(self.repo_url)
     except Exception:
         raise RequirementNotFound(
             f"{self.repo_url} is not a valid VCS url!",
             package=self.package)
     else:
         self.format_desc = format_desc or (lambda n: n)
Ejemplo n.º 3
0
def test_ensure_valid_url(mocker, test_urls):
    """should ensure url is valid"""
    u = test_urls
    with pytest.raises(InvalidURL):
        utils.ensure_valid_url(test_urls["invalid"])
    with pytest.raises(ConnectionError):
        mocker.patch.object(utils, "is_url", return_value=True)
        mock_head = mocker.patch.object(requests, "head")
        mock_head.side_effect = [ConnectionError]
        utils.ensure_valid_url(u["valid"])
    mocker.stopall()
    with pytest.raises(HTTPError):
        utils.ensure_valid_url(u["bad_resp"])
    result = utils.ensure_valid_url(u["valid"])
    assert result == u["valid"]
Ejemplo n.º 4
0
 def __init__(self, name, location, path):
     self.name = name
     self.path = path
     self.location = utils.ensure_valid_url(location)
     self.repos.add(self)