Skip to content

Commit dfbc216

Browse files
author
aviau
committed
Use requests_mock instead of httpretty
1 parent a52f419 commit dfbc216

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
nose
22
mock
3-
httpretty
3+
requests-mock

tests/influxdb/client_test.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import requests
77
import socket
88
import unittest
9-
import httpretty
9+
import requests_mock
1010
from nose.tools import raises
1111
from mock import patch
1212

@@ -332,29 +332,28 @@ def test_delete_database_admin(self):
332332
def test_get_database_user(self):
333333
pass
334334

335-
@httpretty.activate
336335
def test_add_database_user(self):
337-
httpretty.register_uri(
338-
httpretty.POST,
339-
"http://localhost:8086/db/db/users"
340-
)
341-
342-
cli = InfluxDBClient(database='db')
343-
cli.add_database_user(
344-
new_username='paul',
345-
new_password='laup',
346-
permissions=('.*', '.*')
347-
)
336+
with requests_mock.Mocker() as m:
337+
m.register_uri(
338+
requests_mock.POST,
339+
"http://localhost:8086/db/db/users"
340+
)
341+
cli = InfluxDBClient(database='db')
342+
cli.add_database_user(
343+
new_username='paul',
344+
new_password='laup',
345+
permissions=('.*', '.*')
346+
)
348347

349-
self.assertEqual(
350-
httpretty.last_request().parsed_body,
351-
{
352-
u'writeTo': u'.*',
353-
u'password': u'laup',
354-
u'readFrom': u'.*',
355-
u'name': u'paul'
356-
}
357-
)
348+
self.assertDictEqual(
349+
json.loads(m.last_request.body),
350+
{
351+
'writeTo': '.*',
352+
'password': 'laup',
353+
'readFrom': '.*',
354+
'name': 'paul'
355+
}
356+
)
358357

359358
def test_add_database_user_bad_permissions(self):
360359
cli = InfluxDBClient()

0 commit comments

Comments
 (0)