-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add integration tests
- Loading branch information
Showing
9 changed files
with
284 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"MD024": { | ||
"siblings_only": true | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import unittest | ||
|
||
import influxdb_client_3 | ||
|
||
|
||
class TestDeepMerge(unittest.TestCase): | ||
|
||
def test_deep_merge_dicts_with_no_overlap(self): | ||
target = {"a": 1, "b": 2} | ||
source = {"c": 3, "d": 4} | ||
result = influxdb_client_3._deep_merge(target, source) | ||
self.assertEqual(result, {"a": 1, "b": 2, "c": 3, "d": 4}) | ||
|
||
def test_deep_merge_dicts_with_overlap(self): | ||
target = {"a": 1, "b": 2} | ||
source = {"b": 3, "c": 4} | ||
result = influxdb_client_3._deep_merge(target, source) | ||
self.assertEqual(result, {"a": 1, "b": 3, "c": 4}) | ||
|
||
def test_deep_merge_nested_dicts(self): | ||
target = {"a": {"b": 1}} | ||
source = {"a": {"c": 2}} | ||
result = influxdb_client_3._deep_merge(target, source) | ||
self.assertEqual(result, {"a": {"b": 1, "c": 2}}) | ||
|
||
def test_deep_merge_lists(self): | ||
target = [1, 2] | ||
source = [3, 4] | ||
result = influxdb_client_3._deep_merge(target, source) | ||
self.assertEqual(result, [1, 2, 3, 4]) | ||
|
||
def test_deep_merge_non_overlapping_types(self): | ||
target = {"a": 1} | ||
source = [2, 3] | ||
result = influxdb_client_3._deep_merge(target, source) | ||
self.assertEqual(result, [2, 3]) | ||
|
||
def test_deep_merge_none_to_flight(self): | ||
target = { | ||
"headers": [(b"authorization", "Bearer xyz".encode('utf-8'))], | ||
"timeout": 300 | ||
} | ||
source = None | ||
result = influxdb_client_3._deep_merge(target, source) | ||
self.assertEqual(result, target) | ||
|
||
def test_deep_merge_empty_to_flight(self): | ||
target = { | ||
"headers": [(b"authorization", "Bearer xyz".encode('utf-8'))], | ||
"timeout": 300 | ||
} | ||
source = {} | ||
result = influxdb_client_3._deep_merge(target, source) | ||
self.assertEqual(result, target) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import os | ||
import time | ||
import unittest | ||
|
||
import pytest | ||
|
||
from influxdb_client_3 import InfluxDBClient3 | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.skipif( | ||
not all( | ||
[ | ||
os.getenv('TESTING_INFLUXDB_URL'), | ||
os.getenv('TESTING_INFLUXDB_TOKEN'), | ||
os.getenv('TESTING_INFLUXDB_DATABASE'), | ||
] | ||
), | ||
reason="Integration test environment variables not set.", | ||
) | ||
class TestInfluxDBClient3Integration(unittest.TestCase): | ||
|
||
def setUp(self): | ||
host = os.getenv('TESTING_INFLUXDB_URL') | ||
token = os.getenv('TESTING_INFLUXDB_TOKEN') | ||
database = os.getenv('TESTING_INFLUXDB_DATABASE') | ||
|
||
self.client = InfluxDBClient3(host=host, database=database, token=token) | ||
|
||
def tearDown(self): | ||
if self.client: | ||
self.client.close() | ||
|
||
def test_write_and_query(self): | ||
test_id = time.time_ns() | ||
self.client.write(f"integration_test_python,type=used value=123.0,test_id={test_id}i") | ||
|
||
sql = 'SELECT * FROM integration_test_python where type=$type and test_id=$test_id' | ||
|
||
df = self.client.query(sql, mode="pandas", query_parameters={'type': 'used', 'test_id': test_id}) | ||
|
||
self.assertEqual(1, len(df)) | ||
self.assertEqual(test_id, df['test_id'][0]) | ||
self.assertEqual(123.0, df['value'][0]) |
Oops, something went wrong.