def test_update_local_repository_using_update_repo_fail_if_repo_not_found( mocker): responses.add(responses.GET, f"{URL}/api/repositories/{LOCAL_REPOSITORY.key}", status=404) artifactory_repo = ArtifactoryRepository(AuthModel(url=URL, auth=AUTH)) mocker.spy(artifactory_repo, "get_repo") with pytest.raises(RepositoryNotFoundException): artifactory_repo.update_repo(LOCAL_REPOSITORY) artifactory_repo.get_repo.assert_called_once_with(LOCAL_REPOSITORY.key)
def test_update_local_repository_using_update_repo_success(mocker): responses.add( responses.GET, f"{URL}/api/repositories/{UPDATED_LOCAL_REPOSITORY.key}", json=UPDATED_LOCAL_REPOSITORY_RESPONSE.dict(), status=200, ) responses.add( responses.POST, f"{URL}/api/repositories/{UPDATED_LOCAL_REPOSITORY.key}", status=200, ) responses.add( responses.GET, f"{URL}/api/repositories/{UPDATED_LOCAL_REPOSITORY.key}", json=UPDATED_LOCAL_REPOSITORY_RESPONSE.dict(), status=200, ) artifactory_repo = ArtifactoryRepository(AuthModel(url=URL, auth=AUTH)) mocker.spy(artifactory_repo, "get_repo") updated_repo = artifactory_repo.update_repo(UPDATED_LOCAL_REPOSITORY) assert isinstance(updated_repo, LocalRepositoryResponse) assert updated_repo == UPDATED_LOCAL_REPOSITORY_RESPONSE
def test_update_remote_repository_using_update_repo_success(): responses.add( responses.GET, f"{URL}/api/repositories/{UPDATED_REMOTE_REPOSITORY.key}", json=UPDATED_REMOTE_REPOSITORY_RESPONSE.dict(), status=200, ) responses.add( responses.POST, f"{URL}/api/repositories/{UPDATED_REMOTE_REPOSITORY.key}", status=200, ) responses.add( responses.GET, f"{URL}/api/repositories/{UPDATED_REMOTE_REPOSITORY.key}", json=UPDATED_REMOTE_REPOSITORY_RESPONSE.dict(), status=200, ) artifactory_repo = ArtifactoryRepository(AuthModel(url=URL, auth=AUTH)) updated_repo = artifactory_repo.update_repo(UPDATED_REMOTE_REPOSITORY) assert updated_repo == UPDATED_REMOTE_REPOSITORY_RESPONSE