コード例 #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
コード例 #2
0
ファイル: db.py プロジェクト: rajathans/bugbug
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
コード例 #3
0
ファイル: test_utils.py プロジェクト: mahirtaq/bugbug
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
コード例 #4
0
ファイル: test_utils.py プロジェクト: mahirtaq/bugbug
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)
コード例 #5
0
ファイル: test_utils.py プロジェクト: jeffin143/bugbug
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
コード例 #6
0
ファイル: db.py プロジェクト: 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
コード例 #7
0
ファイル: test_utils.py プロジェクト: mahirtaq/bugbug
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
コード例 #8
0
ファイル: test_utils.py プロジェクト: mahirtaq/bugbug
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)
コード例 #9
0
ファイル: db.py プロジェクト: shailendra93/bugbug
def last_modified(path):
    return utils.get_last_modified(DATABASES[path]["url"])