@@ -25,6 +25,19 @@ def test_connection_uri():
25
25
assert connection_uri == expected_connection_uri
26
26
27
27
28
+ def test_server_encoding (connection : psycopg .Connection ):
29
+ """Test that PostgreSQL's encoding is 'UTF-8'."""
30
+
31
+ assert connection .execute ("SHOW SERVER_ENCODING" ).fetchone ()[0 ] == "UTF8"
32
+
33
+
34
+ def test_locale (connection : psycopg .Connection ):
35
+ """Test that PostgreSQL's locale is 'en_US.UTF-8'."""
36
+
37
+ assert connection .execute ("SHOW LC_COLLATE" ).fetchone ()[0 ] == "en_US.UTF-8"
38
+ assert connection .execute ("SHOW LC_CTYPE" ).fetchone ()[0 ] == "en_US.UTF-8"
39
+
40
+
28
41
def test_user_permissions (connection : psycopg .Connection ):
29
42
"""Test that a user can create databases but is not a superuser."""
30
43
@@ -53,6 +66,21 @@ def test_user_create_insert_select(connection: psycopg.Connection):
53
66
assert records == [(1 , "42" )]
54
67
55
68
69
+ def test_user_create_insert_non_ascii (connection : psycopg .Connection ):
70
+ """Test that non-ASCII characters can be stored and fetched."""
71
+
72
+ table_name = "test_setup_postgres"
73
+
74
+ with connection , connection .transaction (force_rollback = True ):
75
+ records = connection \
76
+ .execute (f"CREATE TABLE { table_name } (eggs INTEGER, rice VARCHAR)" ) \
77
+ .execute (f"INSERT INTO { table_name } (eggs, rice) VALUES (1, 'Україна')" ) \
78
+ .execute (f"INSERT INTO { table_name } (eggs, rice) VALUES (2, 'ウクライナ')" ) \
79
+ .execute (f"SELECT * FROM { table_name } " ) \
80
+ .fetchall ()
81
+ assert records == [(1 , "Україна" ), (2 , "ウクライナ" )]
82
+
83
+
56
84
def test_user_create_drop_database (connection : psycopg .Connection ):
57
85
"""Test that a user has no permissions to create databases."""
58
86
0 commit comments