Exemplo n.º 1
0
def test_user_agent():
    assert re.match(
        r"bandersnatch/[0-9]\.[0-9]\.[0-9]\.?d?e?v?[0-9]? \(.*\) " +
        fr"\(aiohttp {aiohttp.__version__}\)",
        user_agent(),
    )
Exemplo n.º 2
0
def test_user_agent():
    assert re.match(
        r"bandersnatch/[0-9]\.[0-9]\.[0-9]\.?d?e?v?[0-9]? \(.*\)", user_agent()
    )
Exemplo n.º 3
0
from pathlib import Path
from sys import stderr
from typing import List, Set  # noqa: F401
from urllib.parse import urlparse

import aiohttp

from bandersnatch.configuration import BandersnatchConfig
from bandersnatch.filter import filter_release_plugins

from bandersnatch.utils import (  # isort:skip
    convert_url_to_path, hash, recursive_find_files, unlink_parent_dir,
    user_agent,
)

ASYNC_USER_AGENT = user_agent(f"aiohttp {aiohttp.__version__}")
logger = logging.getLogger(__name__)


async def get_latest_json(
    json_path: Path,
    config: ConfigParser,
    executor: concurrent.futures.ThreadPoolExecutor,
    delete_removed_packages: bool = False,
) -> None:
    url_parts = urlparse(config.get("mirror", "master"))
    url = f"{url_parts.scheme}://{url_parts.netloc}/pypi/{json_path.name}/json"
    logger.debug(f"Updating {json_path.name} json from {url}")
    new_json_path = json_path.parent / f"{json_path.name}.new"
    await url_fetch(url, new_json_path, executor)
    if new_json_path.exists():
Exemplo n.º 4
0
def test_user_agent_async():
    async_ver = "aiohttp 0.6.9"
    assert re.match(
        fr"bandersnatch/[0-9]\.[0-9]\.[0-9]\.?d?e?v?[0-9]? \(.*\) \({async_ver}\)",
        user_agent(async_ver),
    )
Exemplo n.º 5
0
def test_user_agent():
    ua = user_agent()
    assert "bandersnatch/" in ua