File tree 2 files changed +22
-23
lines changed 2 files changed +22
-23
lines changed Original file line number Diff line number Diff line change 1
1
nose
2
2
mock
3
- httpretty
3
+ requests-mock
Original file line number Diff line number Diff line change 6
6
import requests
7
7
import socket
8
8
import unittest
9
- import httpretty
9
+ import requests_mock
10
10
from nose .tools import raises
11
11
from mock import patch
12
12
@@ -332,29 +332,28 @@ def test_delete_database_admin(self):
332
332
def test_get_database_user (self ):
333
333
pass
334
334
335
- @httpretty .activate
336
335
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
+ )
348
347
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
+ )
358
357
359
358
def test_add_database_user_bad_permissions (self ):
360
359
cli = InfluxDBClient ()
You can’t perform that action at this time.
0 commit comments