Example #1
0
def test_is_downloadable(mocker, test_urls):
    """should check if url can be downloaded from"""
    u = test_urls
    uheaders = u["headers"]
    mock_head = mocker.patch.object(requests, "head")
    head_mock_val = mocker.PropertyMock(
        side_effect=[uheaders["not_download"], uheaders["can_download"]])
    type(mock_head.return_value).headers = head_mock_val
    assert not utils.is_downloadable(u["valid"])
    assert not utils.is_downloadable("not-a-real-url")
    assert utils.is_downloadable(u["valid"])
Example #2
0
    def has_package(self, name):
        """Checks if package is available in repo

        Args:
            name (str): name of package

        Returns:
            bool: True if package is available
        """
        url = self.get_url(name)
        return utils.is_downloadable(url)