From ca81ad108ef02e5190bd3900c8397dd938f5ed0a Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Wed, 5 May 2021 12:37:39 +0300 Subject: [PATCH 1/4] test: tweak test data for the Text type --- test/test_suite.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/test_suite.py b/test/test_suite.py index 3e2d5330..6130c05d 100644 --- a/test/test_suite.py +++ b/test/test_suite.py @@ -45,6 +45,7 @@ from sqlalchemy import String from sqlalchemy.types import Integer from sqlalchemy.types import Numeric +from sqlalchemy.types import Text from sqlalchemy.testing import requires from google.api_core.datetime_helpers import DatetimeWithNanoseconds @@ -87,7 +88,7 @@ from sqlalchemy.testing.suite.test_types import BooleanTest as _BooleanTest from sqlalchemy.testing.suite.test_types import IntegerTest as _IntegerTest from sqlalchemy.testing.suite.test_types import _LiteralRoundTripFixture - +from sqlalchemy.testing.suite.test_types import TextTest as _TextTest from sqlalchemy.testing.suite.test_types import ( # noqa: F401, F403 DateTest as _DateTest, DateTimeHistoricTest, @@ -843,3 +844,22 @@ def test_nolength_binary(self): @pytest.mark.skip("Spanner doesn't support quotes in table names.") class QuotedNameArgumentTest(_QuotedNameArgumentTest): pass + + +class TextTest(_TextTest): + @classmethod + def define_tables(cls, metadata): + """ + SPANNER OVERRIDE: + + Cloud Spanner doesn't support auto incrementing ids feature, + which is used by the original test. Overriding the test data + creation method to disable autoincrement and make id column + nullable. + """ + Table( + "text_table", + metadata, + Column("id", Integer, primary_key=True, nullable=True), + Column("text_data", Text), + ) From b9ccd4a3444279700a0d008c3d8fa1160a8131bd Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Wed, 12 May 2021 11:11:02 +0300 Subject: [PATCH 2/4] del excess overrides --- test/test_suite.py | 54 ---------------------------------------------- 1 file changed, 54 deletions(-) diff --git a/test/test_suite.py b/test/test_suite.py index b3e6f902..755ee82d 100644 --- a/test/test_suite.py +++ b/test/test_suite.py @@ -897,57 +897,3 @@ class StringTest(_StringTest): @pytest.mark.skip("Spanner doesn't support non-ascii characters") def test_literal_non_ascii(self): pass - - -class TextTest(_TextTest): - def test_text_empty_strings(self, connection): - """ - SPANNER OVERRIDE: - - Cloud Spanner doesn't support the tables with an empty primary key - when column has defined NOT NULL - following insertions will fail with - `400 id must not be NULL in table date_table`. - Overriding the tests and adding a manual primary key value to avoid the same - failures. - """ - text_table = self.tables.text_table - - connection.execute(text_table.insert(), {"id": 1, "text_data": ""}) - row = connection.execute(select([text_table.c.text_data])).first() - eq_(row, ("",)) - - def test_text_null_strings(self, connection): - """ - SPANNER OVERRIDE: - - Cloud Spanner doesn't support the tables with an empty primary key - when column has defined NOT NULL - following insertions will fail with - `400 id must not be NULL in table date_table`. - Overriding the tests and adding a manual primary key value to avoid the same - failures. - """ - text_table = self.tables.text_table - - connection.execute(text_table.insert(), {"id": 1, "text_data": None}) - row = connection.execute(select([text_table.c.text_data])).first() - eq_(row, (None,)) - - @pytest.mark.skip("Spanner doesn't support non-ascii characters") - def test_literal_non_ascii(self): - pass - - def test_text_roundtrip(self): - """ - SPANNER OVERRIDE: - - Cloud Spanner doesn't support the tables with an empty primary key - when column has defined NOT NULL - following insertions will fail with - `400 id must not be NULL in table date_table`. - Overriding the tests and adding a manual primary key value to avoid the same - failures. - """ - text_table = self.tables.text_table - - config.db.execute(text_table.insert(), {"id": 1, "text_data": "some text"}) - row = config.db.execute(select([text_table.c.text_data])).first() - eq_(row, ("some text",)) From b835455b7a3a37e5b7af4d99919b9f74b717b127 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Wed, 12 May 2021 11:12:55 +0300 Subject: [PATCH 3/4] del excess import --- test/test_suite.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test_suite.py b/test/test_suite.py index 755ee82d..d6ba8e19 100644 --- a/test/test_suite.py +++ b/test/test_suite.py @@ -91,7 +91,6 @@ from sqlalchemy.testing.suite.test_types import StringTest as _StringTest from sqlalchemy.testing.suite.test_types import TextTest as _TextTest from sqlalchemy.testing.suite.test_types import _LiteralRoundTripFixture -from sqlalchemy.testing.suite.test_types import TextTest as _TextTest from sqlalchemy.testing.suite.test_types import ( # noqa: F401, F403 DateTest as _DateTest, DateTimeHistoricTest, From be83d970b07903973e1d224677880e26de147d96 Mon Sep 17 00:00:00 2001 From: IlyaFaer Date: Tue, 25 May 2021 10:36:22 +0300 Subject: [PATCH 4/4] revert order --- test/test_suite.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/test_suite.py b/test/test_suite.py index 4e97ee5d..d2e79aee 100644 --- a/test/test_suite.py +++ b/test/test_suite.py @@ -775,9 +775,10 @@ def test_nolength_binary(self): foo.drop(config.db) -@pytest.mark.skip("Spanner doesn't support quotes in table names.") -class QuotedNameArgumentTest(_QuotedNameArgumentTest): - pass +class StringTest(_StringTest): + @pytest.mark.skip("Spanner doesn't support non-ascii characters") + def test_literal_non_ascii(self): + pass class TextTest(_TextTest): @@ -1120,12 +1121,6 @@ def test_enotation_decimal(self): ) -class StringTest(_StringTest): - @pytest.mark.skip("Spanner doesn't support non-ascii characters") - def test_literal_non_ascii(self): - pass - - class LikeFunctionsTest(_LikeFunctionsTest): @pytest.mark.skip("Spanner doesn't support LIKE ESCAPE clause") def test_contains_autoescape(self): @@ -1170,6 +1165,11 @@ def test_escape_keyword_raises(self): self._test(col.contains("b##cde", escape="#"), {7}) +@pytest.mark.skip("Spanner doesn't support quotes in table names.") +class QuotedNameArgumentTest(_QuotedNameArgumentTest): + pass + + @pytest.mark.skip("Spanner doesn't support IS DISTINCT FROM clause") class IsOrIsNotDistinctFromTest(_IsOrIsNotDistinctFromTest): pass