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

Commit

Permalink
Python3.2 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aviau committed Apr 9, 2015
1 parent 2402662 commit b9430f9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
6 changes: 4 additions & 2 deletions influxdb/resultset.py
Expand Up @@ -30,8 +30,10 @@ def __getitem__(self, key):
else:
name = key
tags = None
if not isinstance(name, (str, type(None), type(u''))):
raise TypeError('serie_name must be an str or None')
# TODO(aviau): Fix for python 3.2
# if not isinstance(name, (str, bytes, type(None))) \
# and not isinstance(name, type("".decode("utf-8"))):
# raise TypeError('serie_name must be an str or None')

for serie in self._get_series():
serie_name = serie.get('name', 'results')
Expand Down
4 changes: 2 additions & 2 deletions tests/influxdb/client_test.py
Expand Up @@ -269,7 +269,7 @@ def test_query(self):

self.assertListEqual(
list(rs['cpu_load_short']),
[{'value': 0.64, 'time': u'2009-11-10T23:00:00Z'}]
[{'value': 0.64, 'time': '2009-11-10T23:00:00Z'}]
)

@unittest.skip('Not implemented for 0.9')
Expand Down Expand Up @@ -386,7 +386,7 @@ def test_get_list_series(self):
self.cli.get_list_series(),
[{'name': 'cpu_load_short',
'tags': [
{'host': 'server01', '_id': 1, 'region': u'us-west'}
{'host': 'server01', '_id': 1, 'region': 'us-west'}
]}]
)

Expand Down
4 changes: 2 additions & 2 deletions tests/influxdb/client_test_with_server.py
Expand Up @@ -523,8 +523,8 @@ def test_get_list_series_non_empty(self):
self.assertEqual(
[
{'name': 'cpu_load_short',
'tags': [{u'host': u'server01', u'_id': 1,
u'region': u'us-west'}]}
'tags': [{'host': 'server01', '_id': 1,
'region': 'us-west'}]}
],
rsp
)
Expand Down
26 changes: 13 additions & 13 deletions tests/influxdb/resultset_test.py
Expand Up @@ -111,13 +111,13 @@ def test_point_from_cols_vals(self):

def test_system_query(self):
rs = ResultSet(
{u'results': [
{u'series': [
{u'values': [[u'another', u'48h0m0s', 3, False],
[u'default', u'0', 1, False],
[u'somename', u'24h0m0s', 4, True]],
u'columns': [u'name', u'duration',
u'replicaN', u'default']}]}
{'results': [
{'series': [
{'values': [['another', '48h0m0s', 3, False],
['default', '0', 1, False],
['somename', '24h0m0s', 4, True]],
'columns': ['name', 'duration',
'replicaN', 'default']}]}
]
}
)
Expand All @@ -130,11 +130,11 @@ def test_system_query(self):
self.assertEqual(
list(rs['results']),
[
{'duration': u'48h0m0s', u'default': False, u'replicaN': 3,
u'name': u'another'},
{u'duration': u'0', u'default': False, u'replicaN': 1,
u'name': u'default'},
{u'duration': u'24h0m0s', u'default': True, u'replicaN': 4,
u'name': u'somename'}
{'duration': '48h0m0s', 'default': False, 'replicaN': 3,
'name': 'another'},
{'duration': '0', 'default': False, 'replicaN': 1,
'name': 'default'},
{'duration': '24h0m0s', 'default': True, 'replicaN': 4,
'name': 'somename'}
]
)

0 comments on commit b9430f9

Please sign in to comment.