Esempio n. 1
0
def test_set_property_fail_bad_value():
    properties_param_str = urllib.parse.quote_plus(
        f"{BAD_PROPERTY_NAME}={BAD_PROPERTY_VALUE};"
    )
    responses.add(
        responses.PUT,
        f"{URL}/api/storage/{ARTIFACT_PATH}?recursive=1&properties={properties_param_str}",
        status=400,
    )
    artifactory = ArtifactoryArtifact(AuthModel(url=URL, auth=AUTH))
    with pytest.raises(BadPropertiesException):
        set_property_response = artifactory.set_properties(
            ARTIFACT_PATH, {BAD_PROPERTY_NAME: [BAD_PROPERTY_VALUE]}
        )
        assert set_property_response is None
Esempio n. 2
0
def test_set_property_fail_artifact_not_found():
    properties_param_str = ""
    for k, v in ARTIFACT_ONE_PROPERTY.properties.items():
        values_str = ",".join(v)
        properties_param_str += urllib.parse.quote_plus(f"{k}={values_str};")
    responses.add(
        responses.PUT,
        f"{URL}/api/storage/{NX_ARTIFACT_PATH}?recursive=1&properties={properties_param_str}",
        status=404,
    )
    artifactory = ArtifactoryArtifact(AuthModel(url=URL, auth=AUTH))
    with pytest.raises(ArtifactNotFoundException):
        set_property_response = artifactory.set_properties(
            NX_ARTIFACT_PATH, ARTIFACT_ONE_PROPERTY.properties
        )
        assert set_property_response is None
Esempio n. 3
0
def test_set_property_success():
    properties_param_str = ""
    for k, v in ARTIFACT_MULTIPLE_PROPERTIES.properties.items():
        values_str = ",".join(v)
        properties_param_str += urllib.parse.quote_plus(f"{k}={values_str};")
    responses.add(
        responses.PUT,
        f"{URL}/api/storage/{ARTIFACT_PATH}?recursive=1&properties={properties_param_str}",
        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))
    set_properties_response = artifactory.set_properties(
        ARTIFACT_PATH, ARTIFACT_MULTIPLE_PROPERTIES.properties
    )
    assert set_properties_response == ARTIFACT_MULTIPLE_PROPERTIES