示例#1
0
def test_download_artifact_success(tmp_path):
    artifact_name = ARTIFACT_PATH.split("/")[1]
    responses.add(responses.GET,
                  f"{URL}/{ARTIFACT_PATH}",
                  json=artifact_name,
                  status=200)

    artifactory = ArtifactoryArtifact(AuthModel(url=URL, auth=AUTH))
    artifact = artifactory.download(ARTIFACT_PATH, str(tmp_path.resolve()))

    assert artifact == f"{tmp_path.resolve()}/{artifact_name}"
    assert (tmp_path / artifact_name).is_file()
示例#2
0
def test_download_folder_success(tmp_path):
    # artifact_name = ARTIFACT_PATH.split("/")[1]
    responses.add(
        responses.GET,
        f"{URL}/api/storage/{ARTIFACT_REPO}",
        status=200,
        json=FOLDER_INFO_RESPONSE,
    )
    responses.add(
        responses.GET,
        f"{URL}/api/storage/{ARTIFACT_REPO}/child1",
        status=200,
        json=CHILD1_FOLDER_INFO_RESPONSE,
    )
    responses.add(
        responses.GET,
        f"{URL}/api/storage/{ARTIFACT_REPO}/child2",
        status=200,
        json=CHILD2_INFO_RESPONSE,
    )
    responses.add(
        responses.GET,
        f"{URL}/api/storage/{ARTIFACT_REPO}/child1/grandchild",
        status=200,
        json=GRANDCHILD_INFO_RESPONSE,
    )
    responses.add(responses.GET,
                  f"{URL}/{ARTIFACT_REPO}",
                  json="/",
                  status=200)
    responses.add(
        responses.GET,
        f"{URL}/{ARTIFACT_REPO}/child1/grandchild",
        json="/child1/grandchild",
        status=200,
    )
    responses.add(responses.GET,
                  f"{URL}/{ARTIFACT_REPO}/child2",
                  json="/child2",
                  status=200)

    artifactory = ArtifactoryArtifact(AuthModel(url=URL, auth=AUTH))
    artifact = artifactory.download(f"{ARTIFACT_REPO}/",
                                    str(tmp_path.resolve()))

    assert artifact == f"{tmp_path.resolve()}/{ARTIFACT_REPO}"
    assert (tmp_path / f"{ARTIFACT_REPO}" / "child1" / "grandchild").is_file()
    assert (tmp_path / f"{ARTIFACT_REPO}" / "child2").is_file()