Skip to content

Commit dee737d

Browse files
committed
Merge pull request influxdata#190 from kipe/master
Remove dsn.lower() from influxdb08.InfluxDBClient.from_DSN()
2 parents df89dc1 + 8a9b09c commit dee737d

File tree

5 files changed

+59
-59
lines changed

5 files changed

+59
-59
lines changed

influxdb/influxdb08/client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ def from_DSN(dsn, **kwargs):
134134
udp_port parameter (cf. examples).
135135
:raise ValueError: if the provided DSN has any unexpected value.
136136
"""
137-
dsn = dsn.lower()
138137

139138
init_args = {}
140139
conn_params = urlparse(dsn)

tests/influxdb/client_test.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ def setUp(self):
9595
}
9696
]
9797

98+
self.dsn_string = 'influxdb://uSr:pWd@host:1886/db'
99+
98100
def test_scheme(self):
99101
cli = InfluxDBClient('host', 8086, 'username', 'password', 'database')
100102
self.assertEqual('http://host:8086', cli._baseurl)
@@ -105,20 +107,20 @@ def test_scheme(self):
105107
self.assertEqual('https://host:8086', cli._baseurl)
106108

107109
def test_dsn(self):
108-
cli = InfluxDBClient.from_DSN('influxdb://usr:pwd@host:1886/db')
110+
cli = InfluxDBClient.from_DSN(self.dsn_string)
109111
self.assertEqual('http://host:1886', cli._baseurl)
110-
self.assertEqual('usr', cli._username)
111-
self.assertEqual('pwd', cli._password)
112+
self.assertEqual('uSr', cli._username)
113+
self.assertEqual('pWd', cli._password)
112114
self.assertEqual('db', cli._database)
113115
self.assertFalse(cli.use_udp)
114116

115-
cli = InfluxDBClient.from_DSN('udp+influxdb://usr:pwd@host:1886/db')
117+
cli = InfluxDBClient.from_DSN('udp+' + self.dsn_string)
116118
self.assertTrue(cli.use_udp)
117119

118-
cli = InfluxDBClient.from_DSN('https+influxdb://usr:pwd@host:1886/db')
120+
cli = InfluxDBClient.from_DSN('https+' + self.dsn_string)
119121
self.assertEqual('https://host:1886', cli._baseurl)
120122

121-
cli = InfluxDBClient.from_DSN('https+influxdb://usr:pwd@host:1886/db',
123+
cli = InfluxDBClient.from_DSN('https+' + self.dsn_string,
122124
**{'ssl': False})
123125
self.assertEqual('http://host:1886', cli._baseurl)
124126

@@ -742,6 +744,7 @@ def setUp(self):
742744
warnings.simplefilter('error', FutureWarning)
743745

744746
self.hosts = [('host1', 8086), ('host2', 8086), ('host3', 8086)]
747+
self.dsn_string = 'influxdb://uSr:pWd@host1:8086,uSr:pWd@host2:8086/db'
745748

746749
def test_init(self):
747750
cluster = InfluxDBClusterClient(hosts=self.hosts,
@@ -808,33 +811,29 @@ def test_recovery(self):
808811
self.assertEqual(2, len(cluster.bad_clients))
809812

810813
def test_dsn(self):
811-
cli = InfluxDBClusterClient.from_DSN(
812-
'influxdb://usr:pwd@host1:8086,usr:pwd@host2:8086/db')
814+
cli = InfluxDBClusterClient.from_DSN(self.dsn_string)
813815
self.assertEqual(2, len(cli.clients))
814816
self.assertEqual('http://host1:8086', cli.clients[0]._baseurl)
815-
self.assertEqual('usr', cli.clients[0]._username)
816-
self.assertEqual('pwd', cli.clients[0]._password)
817+
self.assertEqual('uSr', cli.clients[0]._username)
818+
self.assertEqual('pWd', cli.clients[0]._password)
817819
self.assertEqual('db', cli.clients[0]._database)
818820
self.assertFalse(cli.clients[0].use_udp)
819821
self.assertEqual('http://host2:8086', cli.clients[1]._baseurl)
820-
self.assertEqual('usr', cli.clients[1]._username)
821-
self.assertEqual('pwd', cli.clients[1]._password)
822+
self.assertEqual('uSr', cli.clients[1]._username)
823+
self.assertEqual('pWd', cli.clients[1]._password)
822824
self.assertEqual('db', cli.clients[1]._database)
823825
self.assertFalse(cli.clients[1].use_udp)
824826

825-
cli = InfluxDBClusterClient.from_DSN(
826-
'udp+influxdb://usr:pwd@host1:8086,usr:pwd@host2:8086/db')
827+
cli = InfluxDBClusterClient.from_DSN('udp+' + self.dsn_string)
827828
self.assertTrue(cli.clients[0].use_udp)
828829
self.assertTrue(cli.clients[1].use_udp)
829830

830-
cli = InfluxDBClusterClient.from_DSN(
831-
'https+influxdb://usr:pwd@host1:8086,usr:pwd@host2:8086/db')
831+
cli = InfluxDBClusterClient.from_DSN('https+' + self.dsn_string)
832832
self.assertEqual('https://host1:8086', cli.clients[0]._baseurl)
833833
self.assertEqual('https://host2:8086', cli.clients[1]._baseurl)
834834

835-
cli = InfluxDBClusterClient.from_DSN(
836-
'https+influxdb://usr:pwd@host1:8086,usr:pwd@host2:8086/db',
837-
**{'ssl': False})
835+
cli = InfluxDBClusterClient.from_DSN('https+' + self.dsn_string,
836+
**{'ssl': False})
838837
self.assertEqual('http://host1:8086', cli.clients[0]._baseurl)
839838
self.assertEqual('http://host2:8086', cli.clients[1]._baseurl)
840839

tests/influxdb/dataframe_client_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_write_points_from_dataframe_in_batches(self):
7575
status_code=204)
7676

7777
cli = DataFrameClient(database='db')
78-
assert cli.write_points(dataframe, "foo", batch_size=1) is True
78+
self.assertTrue(cli.write_points(dataframe, "foo", batch_size=1))
7979

8080
def test_write_points_from_dataframe_with_numeric_column_names(self):
8181
now = pd.Timestamp('1970-01-01 00:00+00:00')
@@ -266,7 +266,7 @@ def test_query_with_empty_result(self):
266266
cli = DataFrameClient('host', 8086, 'username', 'password', 'db')
267267
with _mocked_session(cli, 'GET', 200, {"results": [{}]}):
268268
result = cli.query('select column_one from foo;')
269-
assert result == {}
269+
self.assertEqual(result, {})
270270

271271
def test_list_series(self):
272272
response = {

tests/influxdb/influxdb08/client_test.py

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -89,49 +89,51 @@ def setUp(self):
8989
}
9090
]
9191

92+
self.dsn_string = 'influxdb://uSr:pWd@host:1886/db'
93+
9294
def test_scheme(self):
9395
cli = InfluxDBClient('host', 8086, 'username', 'password', 'database')
94-
assert cli._baseurl == 'http://host:8086'
96+
self.assertEqual(cli._baseurl, 'http://host:8086')
9597

9698
cli = InfluxDBClient(
9799
'host', 8086, 'username', 'password', 'database', ssl=True
98100
)
99-
assert cli._baseurl == 'https://host:8086'
101+
self.assertEqual(cli._baseurl, 'https://host:8086')
100102

101103
def test_dsn(self):
102-
cli = InfluxDBClient.from_DSN('influxdb://usr:pwd@host:1886/db')
103-
assert cli._baseurl == 'http://host:1886'
104-
assert cli._username == 'usr'
105-
assert cli._password == 'pwd'
106-
assert cli._database == 'db'
107-
assert cli.use_udp is False
104+
cli = InfluxDBClient.from_DSN(self.dsn_string)
105+
self.assertEqual('http://host:1886', cli._baseurl)
106+
self.assertEqual('uSr', cli._username)
107+
self.assertEqual('pWd', cli._password)
108+
self.assertEqual('db', cli._database)
109+
self.assertFalse(cli.use_udp)
108110

109-
cli = InfluxDBClient.from_DSN('udp+influxdb://usr:pwd@host:1886/db')
110-
assert cli.use_udp is True
111+
cli = InfluxDBClient.from_DSN('udp+' + self.dsn_string)
112+
self.assertTrue(cli.use_udp)
111113

112-
cli = InfluxDBClient.from_DSN('https+influxdb://usr:pwd@host:1886/db')
113-
assert cli._baseurl == 'https://host:1886'
114+
cli = InfluxDBClient.from_DSN('https+' + self.dsn_string)
115+
self.assertEqual('https://host:1886', cli._baseurl)
114116

115-
cli = InfluxDBClient.from_DSN('https+influxdb://usr:pwd@host:1886/db',
117+
cli = InfluxDBClient.from_DSN('https+' + self.dsn_string,
116118
**{'ssl': False})
117-
assert cli._baseurl == 'http://host:1886'
119+
self.assertEqual('http://host:1886', cli._baseurl)
118120

119121
def test_switch_database(self):
120122
cli = InfluxDBClient('host', 8086, 'username', 'password', 'database')
121123
cli.switch_database('another_database')
122-
assert cli._database == 'another_database'
124+
self.assertEqual(cli._database, 'another_database')
123125

124126
@raises(FutureWarning)
125127
def test_switch_db_deprecated(self):
126128
cli = InfluxDBClient('host', 8086, 'username', 'password', 'database')
127129
cli.switch_db('another_database')
128-
assert cli._database == 'another_database'
130+
self.assertEqual(cli._database, 'another_database')
129131

130132
def test_switch_user(self):
131133
cli = InfluxDBClient('host', 8086, 'username', 'password', 'database')
132134
cli.switch_user('another_username', 'another_password')
133-
assert cli._username == 'another_username'
134-
assert cli._password == 'another_password'
135+
self.assertEqual(cli._username, 'another_username')
136+
self.assertEqual(cli._password, 'another_password')
135137

136138
def test_write(self):
137139
with requests_mock.Mocker() as m:
@@ -250,8 +252,8 @@ def test_write_points_udp(self):
250252

251253
received_data, addr = s.recvfrom(1024)
252254

253-
assert self.dummy_points == \
254-
json.loads(received_data.decode(), strict=True)
255+
self.assertEqual(self.dummy_points,
256+
json.loads(received_data.decode(), strict=True))
255257

256258
def test_write_bad_precision_udp(self):
257259
cli = InfluxDBClient(
@@ -277,7 +279,7 @@ def test_write_points_fails(self):
277279
def test_write_points_with_precision(self):
278280
with _mocked_session('post', 200, self.dummy_points):
279281
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
280-
assert cli.write_points(self.dummy_points) is True
282+
self.assertTrue(cli.write_points(self.dummy_points))
281283

282284
def test_write_points_bad_precision(self):
283285
cli = InfluxDBClient()
@@ -299,13 +301,14 @@ def test_write_points_with_precision_fails(self):
299301
def test_delete_points(self):
300302
with _mocked_session('delete', 204) as mocked:
301303
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
302-
assert cli.delete_points("foo") is True
304+
self.assertTrue(cli.delete_points("foo"))
303305

304-
assert len(mocked.call_args_list) == 1
306+
self.assertEqual(len(mocked.call_args_list), 1)
305307
args, kwds = mocked.call_args_list[0]
306308

307-
assert kwds['params'] == {'u': 'username', 'p': 'password'}
308-
assert kwds['url'] == 'http://host:8086/db/db/series/foo'
309+
self.assertEqual(kwds['params'],
310+
{'u': 'username', 'p': 'password'})
311+
self.assertEqual(kwds['url'], 'http://host:8086/db/db/series/foo')
309312

310313
@raises(Exception)
311314
def test_delete_points_with_wrong_name(self):
@@ -342,7 +345,7 @@ def test_query(self):
342345
with _mocked_session('get', 200, data):
343346
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
344347
result = cli.query('select column_one from foo;')
345-
assert len(result[0]['points']) == 4
348+
self.assertEqual(len(result[0]['points']), 4)
346349

347350
def test_query_chunked(self):
348351
cli = InfluxDBClient(database='db')
@@ -422,7 +425,7 @@ def test_query_bad_precision(self):
422425
def test_create_database(self):
423426
with _mocked_session('post', 201, {"name": "new_db"}):
424427
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
425-
assert cli.create_database('new_db') is True
428+
self.assertTrue(cli.create_database('new_db'))
426429

427430
@raises(Exception)
428431
def test_create_database_fails(self):
@@ -433,7 +436,7 @@ def test_create_database_fails(self):
433436
def test_delete_database(self):
434437
with _mocked_session('delete', 204):
435438
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
436-
assert cli.delete_database('old_db') is True
439+
self.assertTrue(cli.delete_database('old_db'))
437440

438441
@raises(Exception)
439442
def test_delete_database_fails(self):
@@ -447,8 +450,8 @@ def test_get_list_database(self):
447450
]
448451
with _mocked_session('get', 200, data):
449452
cli = InfluxDBClient('host', 8086, 'username', 'password')
450-
assert len(cli.get_list_database()) == 1
451-
assert cli.get_list_database()[0]['name'] == 'a_db'
453+
self.assertEqual(len(cli.get_list_database()), 1)
454+
self.assertEqual(cli.get_list_database()[0]['name'], 'a_db')
452455

453456
@raises(Exception)
454457
def test_get_list_database_fails(self):
@@ -463,8 +466,8 @@ def test_get_database_list_deprecated(self):
463466
]
464467
with _mocked_session('get', 200, data):
465468
cli = InfluxDBClient('host', 8086, 'username', 'password')
466-
assert len(cli.get_database_list()) == 1
467-
assert cli.get_database_list()[0]['name'] == 'a_db'
469+
self.assertEqual(len(cli.get_database_list()), 1)
470+
self.assertEqual(cli.get_database_list()[0]['name'], 'a_db')
468471

469472
def test_delete_series(self):
470473
with _mocked_session('delete', 204):

tests/influxdb/influxdb08/dataframe_client_test.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ def test_write_points_from_dataframe_in_batches(self):
6363
"http://localhost:8086/db/db/series")
6464

6565
cli = DataFrameClient(database='db')
66-
assert cli.write_points({"foo": dataframe},
67-
batch_size=1) is True
66+
self.assertTrue(cli.write_points({"foo": dataframe}, batch_size=1))
6867

6968
def test_write_points_from_dataframe_with_numeric_column_names(self):
7069
now = pd.Timestamp('1970-01-01 00:00+00:00')
@@ -239,15 +238,15 @@ def test_query_multiple_time_series(self):
239238
cli = DataFrameClient('host', 8086, 'username', 'password', 'db')
240239
result = cli.query("""select mean(value), min(value), max(value),
241240
stddev(value) from series1, series2, series3""")
242-
assert dataframes.keys() == result.keys()
241+
self.assertEqual(dataframes.keys(), result.keys())
243242
for key in dataframes.keys():
244243
assert_frame_equal(dataframes[key], result[key])
245244

246245
def test_query_with_empty_result(self):
247246
with _mocked_session('get', 200, []):
248247
cli = DataFrameClient('host', 8086, 'username', 'password', 'db')
249248
result = cli.query('select column_one from foo;')
250-
assert result == []
249+
self.assertEqual(result, [])
251250

252251
def test_list_series(self):
253252
response = [
@@ -260,7 +259,7 @@ def test_list_series(self):
260259
with _mocked_session('get', 200, response):
261260
cli = DataFrameClient('host', 8086, 'username', 'password', 'db')
262261
series_list = cli.get_list_series()
263-
assert series_list == ['seriesA', 'seriesB']
262+
self.assertEqual(series_list, ['seriesA', 'seriesB'])
264263

265264
def test_datetime_to_epoch(self):
266265
timestamp = pd.Timestamp('2013-01-01 00:00:00.000+00:00')

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