From 8a1a49bf6b735659f35311a6fd09a238ab766eaa Mon Sep 17 00:00:00 2001 From: "WQY\\qiong" Date: Tue, 2 May 2023 17:47:50 +0800 Subject: [PATCH] Add test for UTF8 --- api/__init__.py | 1 + test_tjnetwork.py | 15 +++++++++++++++ tjnetwork.py | 12 ++++++++++++ 3 files changed, 28 insertions(+) diff --git a/api/__init__.py b/api/__init__.py index 4d98d94..4fa3293 100644 --- a/api/__init__.py +++ b/api/__init__.py @@ -18,6 +18,7 @@ from .database import get_operation_by_snapshot, get_snapshot_by_operation from .database import pick_snapshot from .database import pick_operation, sync_with_server from .database import get_restore_operation, set_restore_operation, set_restore_operation_to_current, restore +from .database import read, try_read, read_all, write from .batch_exe import execute_batch_commands, execute_batch_command diff --git a/test_tjnetwork.py b/test_tjnetwork.py index f3556e7..a287a7d 100644 --- a/test_tjnetwork.py +++ b/test_tjnetwork.py @@ -19,6 +19,21 @@ class TestApi: delete_project(p) + # encoding + + + def test_utf8(self): + p = 'test_utf8' + self.enter(p) + + write(p, f"create table {p} (a varchar(32))") + write(p, f"insert into {p} values ('你好')") + result = read_all(p, f"select * from { p}") + assert result == [{'a': '你好'}] + + self.leave(p) + + # project diff --git a/tjnetwork.py b/tjnetwork.py index 522f931..208fe9c 100644 --- a/tjnetwork.py +++ b/tjnetwork.py @@ -308,6 +308,18 @@ def set_restore_operation_to_current(name: str) -> None: def restore(name: str, discard: bool = False) -> ChangeSet: return api.restore(name, discard) +def read(name: str, sql: str): + return api.read(name, sql) + +def try_read(name: str, sql: str): + return api.try_read(name, sql) + +def read_all(name: str, sql: str): + return api.read_all(name, sql) + +def write(name: str, sql: str): + return api.write(name, sql) + ############################################################ # type