Exemplo n.º 1
0
def last_modified(path):
    url = DATABASES[path]["url"]
    last_modified = utils.get_last_modified(url)

    if last_modified is None:
        base_url = os.path.splitext(url)[0]
        last_modified = utils.get_last_modified(f"{base_url}.xz")

    if last_modified is None:
        raise Exception("Last-Modified is not available")

    return last_modified
Exemplo n.º 2
0
def last_modified(path):
    url = DATABASES[path]["url"]
    last_modified = utils.get_last_modified(url)

    if last_modified is None:
        raise Exception("Last-Modified is not available")

    return last_modified
Exemplo n.º 3
0
def test_get_last_modified_not_present():
    url = "https://community-tc.services.mozilla.com/api/index/v1/task/project.relman.bugbug/prova.txt"

    responses.add(
        responses.HEAD, url, status=200, headers={"ETag": "123"},
    )

    assert utils.get_last_modified(url) is None
Exemplo n.º 4
0
def test_get_last_modified():
    url = "https://community-tc.services.mozilla.com/api/index/v1/task/project.relman.bugbug/prova.txt"

    responses.add(
        responses.HEAD, url, status=200, headers={"Last-Modified": "2019-04-16",},
    )

    assert utils.get_last_modified(url) == datetime(2019, 4, 16, 0, 0)
Exemplo n.º 5
0
def test_get_last_modified_missing():
    url = "https://community-tc.services.mozilla.com/api/index/v1/task/project.relman.bugbug/prova.txt"

    responses.add(
        responses.HEAD, url, status=404, headers={},
    )

    assert utils.get_last_modified(url) is None
Exemplo n.º 6
0
Arquivo: db.py Projeto: mozilla/bugbug
def last_modified(path):
    if is_different_schema(path):
        raise LastModifiedNotAvailable()

    url = DATABASES[path]["url"]
    last_modified = utils.get_last_modified(url)

    if last_modified is None:
        raise LastModifiedNotAvailable()

    return last_modified
Exemplo n.º 7
0
def test_get_last_modified_missing():
    url = "https://community-tc.services.mozilla.com/api/index/v1/task/project.relman.bugbug/prova.txt"

    responses.add(
        responses.HEAD, url, status=404, headers={},
    )

    url_fallback = url.replace(
        "https://community-tc.services.mozilla.com/api/index",
        "https://index.taskcluster.net",
    )
    responses.add(
        responses.HEAD, url_fallback, status=404, headers={},
    )

    assert utils.get_last_modified(url) is None
Exemplo n.º 8
0
def test_get_last_modified_fallback():
    url = "https://community-tc.services.mozilla.com/api/index/v1/task/project.relman.bugbug/prova.txt"

    responses.add(
        responses.HEAD, url, status=404, headers={"Last-Modified": "2019-04-16"},
    )

    url_fallback = url.replace(
        "https://community-tc.services.mozilla.com/api/index",
        "https://index.taskcluster.net",
    )

    responses.add(
        responses.HEAD,
        url_fallback,
        status=200,
        headers={"Last-Modified": "2018-04-16"},
    )

    assert utils.get_last_modified(url) == datetime(2018, 4, 16, 0, 0)
Exemplo n.º 9
0
def last_modified(path):
    return utils.get_last_modified(DATABASES[path]["url"])