Skip to content

Commit f492bfc

Browse files
author
Christopher Rabotin
committed
Warning tests separated and message now checked.
1 parent b79d9eb commit f492bfc

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

tests/influxdb/helper_test.py

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ class Meta:
120120
AttributeError, cls, **{'time': 159,
121121
'server_name': 'us.east-1'})
122122

123-
def testWarnings(self):
123+
def testWarnBulkSizeZero(self):
124124
'''
125-
Tests warnings for code coverage test.
125+
Tests warning for an invalid bulk size.
126126
'''
127127
class WarnBulkSizeZero(SeriesHelper):
128128

@@ -133,6 +133,24 @@ class Meta:
133133
bulk_size = 0
134134
autocommit = True
135135

136+
with warnings.catch_warnings(record=True) as w:
137+
warnings.simplefilter("always")
138+
try:
139+
WarnBulkSizeZero(time=159, server_name='us.east-1')
140+
except ConnectionError:
141+
# Server defined in the client is invalid, we're testing
142+
# the warning only.
143+
pass
144+
self.assertEqual(len(w), 1,
145+
'{} call should have generated one warning.'
146+
.format(WarnBulkSizeZero))
147+
self.assertIn('forced to 1', str(w[-1].message),
148+
'Warning message did not contain "forced to 1".')
149+
150+
def testWarnBulkSizeNoEffect(self):
151+
'''
152+
Tests warning for a set bulk size but autocommit False.
153+
'''
136154
class WarnBulkSizeNoEffect(SeriesHelper):
137155

138156
class Meta:
@@ -141,15 +159,11 @@ class Meta:
141159
bulk_size = 5
142160
autocommit = False
143161

144-
for cls in [WarnBulkSizeNoEffect, WarnBulkSizeZero]:
145-
with warnings.catch_warnings(record=True) as w:
146-
warnings.simplefilter("always")
147-
try:
148-
cls(time=159, server_name='us.east-1')
149-
except ConnectionError:
150-
# Server defined in the client is invalid, we're testing
151-
# the warning only.
152-
pass
153-
self.assertEqual(len(w), 1,
154-
'{} call should have generated one warning.'
155-
.format(cls))
162+
with warnings.catch_warnings(record=True) as w:
163+
warnings.simplefilter("always")
164+
WarnBulkSizeNoEffect(time=159, server_name='us.east-1')
165+
self.assertEqual(len(w), 1,
166+
'{} call should have generated one warning.'
167+
.format(WarnBulkSizeNoEffect))
168+
self.assertIn('has no affect', str(w[-1].message),
169+
'Warning message did not contain "has not affect".')

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