Skip to content

Commit 38d19ca

Browse files
committed
fix: sync tests
1 parent 77c97d8 commit 38d19ca

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

tests/test_InfluxDBClient.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import threading
55
import unittest
66

7+
import httpretty
78
import pytest
89
from urllib3.exceptions import NewConnectionError, HTTPError
910

@@ -175,11 +176,6 @@ def test_timeout_as_float(self):
175176
write_api.write(bucket="my-bucket", org="my-org", record="mem,tag=a value=1")
176177
self.assertIn("Failed to establish a new connection", str(e.value))
177178

178-
def test_init_without_token(self):
179-
self.client = InfluxDBClient("http://localhost:8086")
180-
self.assertIsNotNone(self.client)
181-
self.client.query_api().query("buckets()", "my-org")
182-
183179

184180
class InfluxDBClientTestIT(BaseTest):
185181
httpRequest = []
@@ -249,6 +245,24 @@ def do_GET(self):
249245
self.httpd_thread.start()
250246

251247

248+
class InfluxDBClientTestMock(unittest.TestCase):
249+
250+
def setUp(self) -> None:
251+
httpretty.enable()
252+
httpretty.reset()
253+
254+
def tearDown(self) -> None:
255+
if self.influxdb_client:
256+
self.influxdb_client.close()
257+
httpretty.disable()
258+
259+
def test_init_without_token(self):
260+
httpretty.register_uri(httpretty.POST, uri="http://localhost/api/v2/query", status=200, body="")
261+
self.influxdb_client = InfluxDBClient("http://localhost")
262+
self.assertIsNotNone(self.influxdb_client)
263+
self.influxdb_client.query_api().query("buckets()", "my-org")
264+
265+
252266
class ServerWithSelfSingedSSL(http.server.SimpleHTTPRequestHandler):
253267
def _set_headers(self):
254268
self.send_response(200)

0 commit comments

Comments
 (0)