cloudant / python-cloudant

A Python library for Cloudant and CouchDB
Apache License 2.0
163 stars 55 forks source link

create_database from CloudDB could silence some errors #465

Closed YiuRULE closed 4 years ago

YiuRULE commented 4 years ago

Please read these guidelines before opening an issue.

Bug Description

1. Steps to reproduce and the simplest code sample possible to demonstrate the issue

We should start at first a couchdb instance, with an foo user, and bar as password for an admin user,

import cloudant

client = cloudant.client.CouchDB(
            None,
            None,
            admin_party=False,
            url="http://localhost",
            connect=True
)
client.create_database("my_database")

2. What you expected to happen

create_database should launch an error than the current user doesn't have a write access. As we have with the create method for the CloudantDatabase class.

import cloudant
client = cloudant.client.CouchDB(
            None,
            None,
            admin_party=False,
            url="http://localhost",
            connect=True
)
cloudant.database.CloudantDatabase(client name).create(throw_on_exists=False)

will return this exception

cloudant.error.CloudantDatabaseException: Unauthorized to create database http://localhost:5984/my_database

3. What actually happened

It will never launch an exception and will consider the database creation as successful, while the database would never be created.

Environment details

bessbd commented 4 years ago

Hi @YiuRULE ,

Thank you for this ticket! According to the "environment details" section of the issue description, you are using "2.13.0". However, https://github.com/cloudant/python-cloudant/pull/447/ is supposed to fix this issue which was included with 2.13.0. (FWIW, 2.13.0 was released 4 days ago - https://github.com/cloudant/python-cloudant/releases/tag/2.13.0 ).

Can you please confirm that the version that's being imported and used is actually the latest? You can do it by adding a line of

print(cloudant.__version__)

right after your import cloudant line.

Thank you,

Donat

YiuRULE commented 4 years ago

Oh yes, probably messed up a bit with my test on my local environment, it was inded fixed on 2.13.0

I will close the issue, thanks :)

bessbd commented 4 years ago

I'm glad to hear this is solved now! Thanks for reporting the resolution and closing the ticket, @YiuRULE !