Esempio n. 1
0
def mock_component_taskcluster_artifact() -> None:
    responses.add(
        responses.HEAD,
        "https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/gecko.v2.mozilla-central.latest.source.source-bugzilla-info/artifacts/public/components.json",
        status=200,
        headers={"ETag": "100"},
    )

    responses.add(
        responses.GET,
        "https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/gecko.v2.mozilla-central.latest.source.source-bugzilla-info/artifacts/public/components.json",
        status=200,
        json={},
    )

    repository.download_component_mapping()
Esempio n. 2
0
def test_download_component_mapping():
    responses.add(
        responses.HEAD,
        "https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/gecko.v2.mozilla-central.latest.source.source-bugzilla-info/artifacts/public/components.json",
        status=200,
        headers={"ETag": "100"},
    )

    responses.add(
        responses.GET,
        "https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/gecko.v2.mozilla-central.latest.source.source-bugzilla-info/artifacts/public/components.json",
        status=200,
        json={},
    )

    repository.download_component_mapping()
    assert len(repository.path_to_component) == 0

    responses.reset()
    responses.add(
        responses.HEAD,
        "https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/gecko.v2.mozilla-central.latest.source.source-bugzilla-info/artifacts/public/components.json",
        status=200,
        headers={"ETag": "101"},
    )

    responses.add(
        responses.GET,
        "https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/gecko.v2.mozilla-central.latest.source.source-bugzilla-info/artifacts/public/components.json",
        status=200,
        json={
            "AUTHORS": ["mozilla.org", "Licensing"],
            "Cargo.lock": ["Firefox Build System", "General"],
        },
    )

    repository.download_component_mapping()
    assert len(repository.path_to_component) == 2
    assert repository.path_to_component["AUTHORS"] == "mozilla.org::Licensing"
    assert repository.path_to_component[
        "Cargo.lock"] == "Firefox Build System::General"

    responses.reset()
    responses.add(
        responses.HEAD,
        "https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/gecko.v2.mozilla-central.latest.source.source-bugzilla-info/artifacts/public/components.json",
        status=200,
        headers={"ETag": "101"},
    )

    repository.download_component_mapping()
    assert len(repository.path_to_component) == 2
    assert repository.path_to_component["AUTHORS"] == "mozilla.org::Licensing"
    assert repository.path_to_component[
        "Cargo.lock"] == "Firefox Build System::General"