Project

Profile

Help

Issue #4903 ยป test_repo_bindings.py

Reproducer - mdellweg, 06/03/2019 08:55 PM

 
#!/usr/bin/env python

import time

from pulpcore.client import pulpcore


config = pulpcore.Configuration()
config.safe_chars_for_path_param = '/'
config.host = "http://localhost:24817"
config.username = "admin"
config.password = "password"

client = pulpcore.ApiClient(config)

tasks_api = pulpcore.TasksApi(client)
repositories_api = pulpcore.RepositoriesApi(client)

repository = pulpcore.Repository(name='test_repo', description='to be nullified')
result = repositories_api.repositories_create(repository)
print("Freshly created:")
print(result)
repo_href = result._href

try:
# Now try to nullify the description
repository.description = None
# First try (PUT)
repositories_api.repositories_update(repo_href, repository)
time.sleep(1) # too lazy to do the tasks thing
result = repositories_api.repositories_read(repo_href)
print("Tried to change (1):")
print(result)

# Second try (PATCH)
repositories_api.repositories_partial_update(repo_href, repository)
time.sleep(1) # too lazy to do the tasks thing
result = repositories_api.repositories_read(repo_href)
print("Tried to change (2):")
print(result)

finally:
repositories_api.repositories_delete(repo_href)
    (1-1/1)