-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement CouchDB.info() #9
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but it needs the wrapping of the aiohttp
exceptions. I suggested my preferred way to do it inline.
aiocouch/couchdb.py
Outdated
@@ -39,3 +39,6 @@ def __init__(self, *args, **kwargs): | |||
|
|||
async def keys(self, **params): | |||
return await self._server._all_dbs(**params) | |||
|
|||
async def info(self): | |||
return await self._server._get('/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an _info()
method to RemoteServer and add the @raises
decorator for the 401 to that new method. Just like the _check_session
method there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and please use "
instead of '
. That's probably, what the black CI step is complaining about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
Add function to get CouchDB server information (i.e. `GET /`). This allows, for example, getting the server version with: couchdb = CouchDB(url) info = await couchdb.info() print(info['version'])
a652597
to
037b337
Compare
I updated the pull request thanks to your suggestion. Here is the diff since last time: --- a/aiocouch/couchdb.py
+++ b/aiocouch/couchdb.py
@@ -41,4 +41,4 @@ class CouchDB(object):
return await self._server._all_dbs(**params)
async def info(self):
- return await self._server._get('/')
+ return await self._server._info()
--- a/aiocouch/remote.py
+++ b/aiocouch/remote.py
@@ -103,6 +103,10 @@ class RemoteServer(object):
await self._http_session.close()
await asyncio.sleep(0.250 if has_ssl_conn else 0)
+ @raises(401, "Invalid credentials")
+ async def _info(self):
+ return await self._get("/")
+
@raises(401, "Authentification failed, check provided credentials.")
async def _check_session(self):
await self._get("/_session") |
Add function to get CouchDB server information (i.e.
GET /
). Thisallows, for example, getting the server version with: