-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: yehao <[email protected]>
- Loading branch information
Showing
3 changed files
with
144 additions
and
1 deletion.
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
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,33 @@ | ||
import time | ||
import unittest | ||
from datetime import datetime | ||
|
||
import requests | ||
from opengemini_client import models | ||
from opengemini_client import test_utils | ||
|
||
|
||
class WriteTest(unittest.TestCase): | ||
|
||
def test_write_batch_points_success(self): | ||
with test_utils.get_test_default_client() as cli: | ||
cli.create_database('write_test') | ||
point = models.Point(measurement='write_mm', precision=models.PrecisionType.PrecisionSecond, | ||
fields={'x': 12.0, 'y': 4.0}, tags={'a': 'ax', 'b': 'bx'}, timestamp=datetime.now()) | ||
cli.write_batch_points("write_test", models.BatchPoints(points=[point])) | ||
time.sleep(3) | ||
qr = cli.query(models.Query(database='write_test', command='select * from write_mm', retention_policy='')) | ||
print(qr) | ||
self.assertNotEqual(len(qr.results), 0) | ||
result = qr.results[0] | ||
series = result.series | ||
self.assertNotEqual(len(series), 0) | ||
cli.drop_database('write_test') | ||
|
||
def test_write_batch_points_fail_with_no_database(self): | ||
with test_utils.get_test_default_client() as cli: | ||
point = models.Point(measurement='write_mm', precision=models.PrecisionType.PrecisionSecond, | ||
fields={'x': 6.0, 'y': 4.0}, timestamp=datetime.now()) | ||
with self.assertRaises(requests.exceptions.HTTPError) as context: | ||
cli.write_batch_points("write_test1", models.BatchPoints(points=[point])) | ||
self.assertRegex(str(context.exception), "database not found") |