Skip to content

Commit ed17eda

Browse files
committed
Use six for python3/2 compatibility
1 parent 56cab64 commit ed17eda

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

influxdb/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
python client for influxdb
44
"""
55
import json
6-
import urllib
6+
7+
from six.moves.urllib.parse import urlencode
78

89
import requests
910

@@ -169,7 +170,7 @@ def query(self, query, time_precision='s', chunked=False):
169170
else:
170171
chunked_param = 'false'
171172

172-
encoded_query = urllib.urlencode({
173+
encoded_query = urlencode({
173174
'q': query})
174175

175176
url_format = "{0}/db/{1}/series?{2}&u={3}&p={4}"

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
six
12
requests

tests/influxdb/client_test.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"""
33
unit tests
44
"""
5+
import json
6+
57
import requests
68
from nose.tools import raises
79
from mock import patch
@@ -97,7 +99,14 @@ def test_remove_scheduled_delete(self):
9799
cli.remove_scheduled_delete(1)
98100

99101
def test_query(self):
100-
pass
102+
expected = """[{"name":"foo","columns":["time","sequence_number","column_one"],"points":[[1383876043,16,"2"],[1383876043,15,"1"],[1383876035,14,"2"],[1383876035,13,"1"]]}]"""
103+
with patch.object(requests, 'get') as mocked_get:
104+
mocked_get.return_value = _build_response_object(
105+
status_code=200,
106+
content=expected)
107+
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
108+
result = cli.query('select column_one from foo;')
109+
assert len(json.loads(result)[0]['points']) == 4
101110

102111
def test_create_database(self):
103112
with patch.object(requests, 'post') as mocked_post:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy