Skip to content

Commit f3ca437

Browse files
test: add text compliance tests (#36)
* test: add text compliance tests * test: enable skipped test * test: nit Co-authored-by: larkee <[email protected]>
1 parent aa67b08 commit f3ca437

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

test/test_suite.py

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
from sqlalchemy.testing.suite.test_types import BooleanTest as _BooleanTest
8989
from sqlalchemy.testing.suite.test_types import IntegerTest as _IntegerTest
9090
from sqlalchemy.testing.suite.test_types import StringTest as _StringTest
91-
91+
from sqlalchemy.testing.suite.test_types import TextTest as _TextTest
9292
from sqlalchemy.testing.suite.test_types import _LiteralRoundTripFixture
9393

9494
from sqlalchemy.testing.suite.test_types import ( # noqa: F401, F403
@@ -873,3 +873,57 @@ class StringTest(_StringTest):
873873
@pytest.mark.skip("Spanner doesn't support non-ascii characters")
874874
def test_literal_non_ascii(self):
875875
pass
876+
877+
878+
class TextTest(_TextTest):
879+
def test_text_empty_strings(self, connection):
880+
"""
881+
SPANNER OVERRIDE:
882+
883+
Cloud Spanner doesn't support the tables with an empty primary key
884+
when column has defined NOT NULL - following insertions will fail with
885+
`400 id must not be NULL in table date_table`.
886+
Overriding the tests and adding a manual primary key value to avoid the same
887+
failures.
888+
"""
889+
text_table = self.tables.text_table
890+
891+
connection.execute(text_table.insert(), {"id": 1, "text_data": ""})
892+
row = connection.execute(select([text_table.c.text_data])).first()
893+
eq_(row, ("",))
894+
895+
def test_text_null_strings(self, connection):
896+
"""
897+
SPANNER OVERRIDE:
898+
899+
Cloud Spanner doesn't support the tables with an empty primary key
900+
when column has defined NOT NULL - following insertions will fail with
901+
`400 id must not be NULL in table date_table`.
902+
Overriding the tests and adding a manual primary key value to avoid the same
903+
failures.
904+
"""
905+
text_table = self.tables.text_table
906+
907+
connection.execute(text_table.insert(), {"id": 1, "text_data": None})
908+
row = connection.execute(select([text_table.c.text_data])).first()
909+
eq_(row, (None,))
910+
911+
@pytest.mark.skip("Spanner doesn't support non-ascii characters")
912+
def test_literal_non_ascii(self):
913+
pass
914+
915+
def test_text_roundtrip(self):
916+
"""
917+
SPANNER OVERRIDE:
918+
919+
Cloud Spanner doesn't support the tables with an empty primary key
920+
when column has defined NOT NULL - following insertions will fail with
921+
`400 id must not be NULL in table date_table`.
922+
Overriding the tests and adding a manual primary key value to avoid the same
923+
failures.
924+
"""
925+
text_table = self.tables.text_table
926+
927+
config.db.execute(text_table.insert(), {"id": 1, "text_data": "some text"})
928+
row = config.db.execute(select([text_table.c.text_data])).first()
929+
eq_(row, ("some text",))

0 commit comments

Comments
 (0)