diff --git a/cloudkitty/storage/v2/influx.py b/cloudkitty/storage/v2/influx.py index 2f95846c..85cfd152 100644 --- a/cloudkitty/storage/v2/influx.py +++ b/cloudkitty/storage/v2/influx.py @@ -23,7 +23,6 @@ import six from cloudkitty.storage import v2 as v2_storage from cloudkitty import tzutils -from cloudkitty import utils LOG = log.getLogger(__name__) @@ -208,10 +207,10 @@ class InfluxClient(object): def _get_time_query_delete(begin, end): output = "" if begin: - output += " WHERE time >= '{}'".format(utils.isotime(begin)) + output += " WHERE time >= '{}'".format(begin.isoformat()) if end: output += " AND " if output else " WHERE " - output += "time < '{}'".format(utils.isotime(end)) + output += "time < '{}'".format(end.isoformat()) return output def delete(self, begin, end, filters): diff --git a/cloudkitty/tests/storage/v2/test_influxdb.py b/cloudkitty/tests/storage/v2/test_influxdb.py index c95f7a61..90207ad5 100644 --- a/cloudkitty/tests/storage/v2/test_influxdb.py +++ b/cloudkitty/tests/storage/v2/test_influxdb.py @@ -88,8 +88,8 @@ class TestInfluxClient(unittest.TestCase): self._storage.delete(begin=datetime(2019, 1, 1), end=datetime(2019, 1, 2)) m.assert_called_once_with( - """DELETE FROM "dataframes" WHERE time >= '2019-01-01T00:00:00Z'""" - """ AND time < '2019-01-02T00:00:00Z';""") + """DELETE FROM "dataframes" WHERE time >= '2019-01-01T00:00:00'""" + """ AND time < '2019-01-02T00:00:00';""") def test_delete_begin_end_filters(self): self._storage._conn._conn.query = m = mock.MagicMock() @@ -97,8 +97,8 @@ class TestInfluxClient(unittest.TestCase): begin=datetime(2019, 1, 1), end=datetime(2019, 1, 2), filters={'project_id': 'foobar'}) m.assert_called_once_with( - """DELETE FROM "dataframes" WHERE time >= '2019-01-01T00:00:00Z'""" - """ AND time < '2019-01-02T00:00:00Z' AND "project_id"='foobar';""" + """DELETE FROM "dataframes" WHERE time >= '2019-01-01T00:00:00'""" + """ AND time < '2019-01-02T00:00:00' AND "project_id"='foobar';""" ) def test_delete_end_filters(self): @@ -106,7 +106,7 @@ class TestInfluxClient(unittest.TestCase): self._storage.delete(end=datetime(2019, 1, 2), filters={'project_id': 'foobar'}) m.assert_called_once_with( - """DELETE FROM "dataframes" WHERE time < '2019-01-02T00:00:00Z' """ + """DELETE FROM "dataframes" WHERE time < '2019-01-02T00:00:00' """ """AND "project_id"='foobar';""") def test_delete_begin_filters(self): @@ -114,17 +114,17 @@ class TestInfluxClient(unittest.TestCase): self._storage.delete(begin=datetime(2019, 1, 2), filters={'project_id': 'foobar'}) m.assert_called_once_with( - """DELETE FROM "dataframes" WHERE time >= '2019-01-02T00:00:00Z'""" + """DELETE FROM "dataframes" WHERE time >= '2019-01-02T00:00:00'""" """ AND "project_id"='foobar';""") def test_delete_begin(self): self._storage._conn._conn.query = m = mock.MagicMock() self._storage.delete(begin=datetime(2019, 1, 2)) m.assert_called_once_with("""DELETE FROM "dataframes" WHERE """ - """time >= '2019-01-02T00:00:00Z';""") + """time >= '2019-01-02T00:00:00';""") def test_delete_end(self): self._storage._conn._conn.query = m = mock.MagicMock() self._storage.delete(end=datetime(2019, 1, 2)) m.assert_called_once_with("""DELETE FROM "dataframes" WHERE """ - """time < '2019-01-02T00:00:00Z';""") + """time < '2019-01-02T00:00:00';""")