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

Commit

Permalink
Dont ignore FutureWarnings in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aviau committed Dec 29, 2014
1 parent c720f97 commit 064f2d2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
6 changes: 2 additions & 4 deletions influxdb/dataframe_client.py
Expand Up @@ -55,15 +55,13 @@ def write_points(self, data, *args, **kwargs):
name=key,
dataframe=data_frame.ix[start_index:end_index].copy(),
time_precision=time_precision)]
InfluxDBClient.write_points_with_precision(self, data,
*args, **kwargs)
InfluxDBClient.write_points(self, data, *args, **kwargs)
return True
else:
data = [self._convert_dataframe_to_json(
name=key, dataframe=dataframe, time_precision=time_precision)
for key, dataframe in data.items()]
return InfluxDBClient.write_points_with_precision(self, data,
*args, **kwargs)
return InfluxDBClient.write_points(self, data, *args, **kwargs)

def write_points_with_precision(self, data, time_precision='s'):
"""
Expand Down
14 changes: 6 additions & 8 deletions tests/influxdb/client_test.py
Expand Up @@ -62,8 +62,8 @@ def request(*args, **kwargs):
class TestInfluxDBClient(unittest.TestCase):

def setUp(self):
# By default, ignore warnings
warnings.simplefilter('ignore', FutureWarning)
# By default, raise exceptions on warnings
warnings.simplefilter('error', FutureWarning)

self.dummy_points = [
{
Expand Down Expand Up @@ -92,7 +92,6 @@ def test_switch_database(self):

@raises(FutureWarning)
def test_switch_db_deprecated(self):
warnings.simplefilter('error', FutureWarning)
cli = InfluxDBClient('host', 8086, 'username', 'password', 'database')
cli.switch_db('another_database')
assert cli._database == 'another_database'
Expand Down Expand Up @@ -170,7 +169,7 @@ def test_write_bad_precision_udp(self):
Exception,
"InfluxDB only supports seconds precision for udp writes"
):
cli.write_points_with_precision(
cli.write_points(
self.dummy_points,
time_precision='ms'
)
Expand All @@ -184,15 +183,15 @@ def test_write_points_fails(self):
def test_write_points_with_precision(self):
with _mocked_session('post', 200, self.dummy_points):
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
assert cli.write_points_with_precision(self.dummy_points) is True
assert cli.write_points(self.dummy_points) is True

def test_write_points_bad_precision(self):
cli = InfluxDBClient()
with self.assertRaisesRegexp(
Exception,
"Invalid time precision is given. \(use 's', 'm', 'ms' or 'u'\)"
):
cli.write_points_with_precision(
cli.write_points(
self.dummy_points,
time_precision='g'
)
Expand Down Expand Up @@ -325,7 +324,7 @@ def test_get_list_database(self):
]
with _mocked_session('get', 200, data):
cli = InfluxDBClient('host', 8086, 'username', 'password')
assert len(cli.get_database_list()) == 1
assert len(cli.get_list_database()) == 1
assert cli.get_list_database()[0]['name'] == 'a_db'

@raises(Exception)
Expand All @@ -336,7 +335,6 @@ def test_get_list_database_fails(self):

@raises(FutureWarning)
def test_get_database_list_deprecated(self):
warnings.simplefilter('error', FutureWarning)
data = [
{"name": "a_db"}
]
Expand Down
5 changes: 5 additions & 0 deletions tests/influxdb/dataframe_client_test.py
Expand Up @@ -9,6 +9,7 @@
from datetime import timedelta
from tests import skipIfPYpy, using_pypy
import copy
import warnings

if not using_pypy:
import pandas as pd
Expand All @@ -21,6 +22,10 @@
@skipIfPYpy
class TestDataFrameClient(unittest.TestCase):

def setUp(self):
# By default, raise exceptions on warnings
warnings.simplefilter('error', FutureWarning)

def test_write_points_from_dataframe(self):
now = pd.Timestamp('1970-01-01 00:00+00:00')
dataframe = pd.DataFrame(data=[["1", 1, 1.0], ["2", 2, 2.0]],
Expand Down

0 comments on commit 064f2d2

Please sign in to comment.