Esempio n. 1
0
def test_update_property_fail_artifact_not_found():
    responses.add(
        responses.PATCH,
        f"{URL}/api/metadata/{NX_ARTIFACT_PATH}?recursive=1",
        match=[
            responses.matchers.json_params_matcher(
                {"props": ARTIFACT_ONE_PROPERTY.properties}
            )
        ],
        status=400,
    )
    artifactory = ArtifactoryArtifact(AuthModel(url=URL, auth=AUTH))
    with pytest.raises(ArtifactoryException):
        update_properties_response = artifactory.update_properties(
            NX_ARTIFACT_PATH, ARTIFACT_ONE_PROPERTY.properties
        )
        assert update_properties_response is None
Esempio n. 2
0
def test_update_property_fail_bad_value():
    responses.add(
        responses.PATCH,
        f"{URL}/api/metadata/{ARTIFACT_PATH}?recursive=1",
        match=[
            responses.matchers.json_params_matcher(
                {"props": {BAD_PROPERTY_NAME: [BAD_PROPERTY_VALUE]}}
            )
        ],
        status=400,
    )
    artifactory = ArtifactoryArtifact(AuthModel(url=URL, auth=AUTH))
    with pytest.raises(ArtifactoryException):
        update_properties_response = artifactory.update_properties(
            ARTIFACT_PATH, {BAD_PROPERTY_NAME: [BAD_PROPERTY_VALUE]}
        )
        assert update_properties_response is None
Esempio n. 3
0
def test_update_property_success():
    responses.add(
        responses.PATCH,
        f"{URL}/api/metadata/{ARTIFACT_PATH}?recursive=1",
        match=[
            responses.matchers.json_params_matcher(
                {"props": ARTIFACT_MULTIPLE_PROPERTIES.properties}
            )
        ],
        status=200,
    )
    responses.add(
        responses.GET,
        f"{URL}/api/storage/{ARTIFACT_PATH}?properties=",
        json=ARTIFACT_MULTIPLE_PROPERTIES.dict(),
        status=200,
    )
    artifactory = ArtifactoryArtifact(AuthModel(url=URL, auth=AUTH))
    update_properties_response = artifactory.update_properties(
        ARTIFACT_PATH, ARTIFACT_MULTIPLE_PROPERTIES.properties
    )
    assert update_properties_response == ARTIFACT_MULTIPLE_PROPERTIES