Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Use requests_mock instead of httpretty
Browse files Browse the repository at this point in the history
  • Loading branch information
aviau committed Oct 30, 2014
1 parent 8b29770 commit 8537be7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion test-requirements.txt
@@ -1,3 +1,3 @@
nose
mock
httpretty
requests-mock
43 changes: 21 additions & 22 deletions tests/influxdb/client_test.py
Expand Up @@ -6,7 +6,7 @@
import requests
import socket
import unittest
import httpretty
import requests_mock
from nose.tools import raises
from mock import patch

Expand Down Expand Up @@ -332,29 +332,28 @@ def test_delete_database_admin(self):
def test_get_database_user(self):
pass

@httpretty.activate
def test_add_database_user(self):
httpretty.register_uri(
httpretty.POST,
"http://localhost:8086/db/db/users"
)

cli = InfluxDBClient(database='db')
cli.add_database_user(
new_username='paul',
new_password='laup',
permissions=('.*', '.*')
)
with requests_mock.Mocker() as m:
m.register_uri(
requests_mock.POST,
"http://localhost:8086/db/db/users"
)
cli = InfluxDBClient(database='db')
cli.add_database_user(
new_username='paul',
new_password='laup',
permissions=('.*', '.*')
)

self.assertEqual(
httpretty.last_request().parsed_body,
{
u'writeTo': u'.*',
u'password': u'laup',
u'readFrom': u'.*',
u'name': u'paul'
}
)
self.assertDictEqual(
json.loads(m.last_request.body),
{
'writeTo': '.*',
'password': 'laup',
'readFrom': '.*',
'name': 'paul'
}
)

def test_add_database_user_bad_permissions(self):
cli = InfluxDBClient()
Expand Down

0 comments on commit 8537be7

Please sign in to comment.