You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by jf...@apache.org on 2021/03/26 09:16:59 UTC
[iotdb] 02/04: Added first test.
This is an automated email from the ASF dual-hosted git repository.
jfeinauer pushed a commit to branch feature/restrucutre-python-module
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 5c9e579d9f90a0ed84dfa2ec3fb75ddcd30bfdb4
Author: Julian Feinauer <j....@pragmaticminds.de>
AuthorDate: Fri Mar 26 09:44:37 2021 +0100
Added first test.
---
client-py/iotdb/Session.py | 4 ++++
client-py/{src => }/iotdb/TestContainer.py | 0
client-py/requirements.txt | 5 ++++-
client-py/requirements_dev.txt | 5 ++++-
client-py/tests/__init__.py | 0
client-py/tests/test_dataframe.py | 23 +++++++++++++++++++----
6 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/client-py/iotdb/Session.py b/client-py/iotdb/Session.py
index e371423..e55a692 100644
--- a/client-py/iotdb/Session.py
+++ b/client-py/iotdb/Session.py
@@ -225,6 +225,10 @@ class Session(object):
def insert_str_record(self, device_id, timestamp, measurements, string_values):
""" special case for inserting one row of String (TEXT) value """
+ if type(string_values) == str:
+ string_values = [string_values]
+ if type(measurements) == str:
+ measurements = [measurements]
data_types = [TSDataType.TEXT.value for _ in string_values]
request = self.gen_insert_str_record_req(device_id, timestamp, measurements, data_types, string_values)
status = self.__client.insertStringRecord(request)
diff --git a/client-py/src/iotdb/TestContainer.py b/client-py/iotdb/TestContainer.py
similarity index 100%
rename from client-py/src/iotdb/TestContainer.py
rename to client-py/iotdb/TestContainer.py
diff --git a/client-py/requirements.txt b/client-py/requirements.txt
index bbd21b4..39c5e61 100644
--- a/client-py/requirements.txt
+++ b/client-py/requirements.txt
@@ -1 +1,4 @@
-pandas==1.2.3
\ No newline at end of file
+# Pandas Export
+pandas==1.2.3
+# Testcontainer
+testcontainers==3.3.0
\ No newline at end of file
diff --git a/client-py/requirements_dev.txt b/client-py/requirements_dev.txt
index 8aa50dd..0ee3c7c 100644
--- a/client-py/requirements_dev.txt
+++ b/client-py/requirements_dev.txt
@@ -1 +1,4 @@
-pytest==6.2.2
\ No newline at end of file
+-r requirements.txt
+# Pytest to run tests
+pytest==6.2.2
+thrift==0.13.0
\ No newline at end of file
diff --git a/client-py/tests/__init__.py b/client-py/tests/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/client-py/tests/test_dataframe.py b/client-py/tests/test_dataframe.py
index fa41274..988caaf 100644
--- a/client-py/tests/test_dataframe.py
+++ b/client-py/tests/test_dataframe.py
@@ -1,5 +1,20 @@
-def test_something():
- assert 2 == 1+1
+from iotdb.Session import Session
+from iotdb.TestContainer import IoTDBContainer
-def test_something_2():
- assert 2 == 1+1+1
\ No newline at end of file
+
+def test_simple_query():
+ with IoTDBContainer("apache/iotdb:0.11.2") as db:
+ db: IoTDBContainer
+ session = Session(db.get_container_host_ip(), db.get_exposed_port(6667))
+ session.open(False)
+
+ # Write data
+ session.insert_str_record("device", 123, "pressure", "15.0")
+
+ # Read
+ session_data_set = session.execute_query_statement("SELECT * FROM root.*")
+ df = session_data_set.todf()
+
+ session.close()
+
+ assert df == []
\ No newline at end of file