From 1fc379f4a6ffff3602a07f0817127271a39a1188 Mon Sep 17 00:00:00 2001 From: AlexandrovRoman Date: Tue, 20 Aug 2024 01:12:22 +0400 Subject: [PATCH] Fixup spaces count --- tests/sync_enum_values/test_array_column.py | 8 ++++---- tests/sync_enum_values/test_render.py | 8 ++++---- tests/sync_enum_values/test_run_array_new_column.py | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/sync_enum_values/test_array_column.py b/tests/sync_enum_values/test_array_column.py index 573cfe4..0c6b87a 100644 --- a/tests/sync_enum_values/test_array_column.py +++ b/tests/sync_enum_values/test_array_column.py @@ -39,14 +39,14 @@ def test_add_new_enum_value_render_with_array(connection: "Connection"): autogenerate._render_migration_diffs(context, template_args) assert template_args["imports"] == ( - "from alembic_postgresql_enum import ColumnType # type: ignore[attr-defined]" - "\nfrom alembic_postgresql_enum import TableReference # type: ignore[attr-defined]" + "from alembic_postgresql_enum import ColumnType # type: ignore[attr-defined]" + "\nfrom alembic_postgresql_enum import TableReference # type: ignore[attr-defined]" ) assert ( template_args["upgrades"] == f"""# ### commands auto generated by Alembic - please adjust! ### - op.sync_enum_values('{DEFAULT_SCHEMA}', '{CAR_COLORS_ENUM_NAME}', [{', '.join(map(repr, new_enum_variants))}], # type: ignore[attr-defined] + op.sync_enum_values('{DEFAULT_SCHEMA}', '{CAR_COLORS_ENUM_NAME}', [{', '.join(map(repr, new_enum_variants))}], # type: ignore[attr-defined] [TableReference(table_schema='{DEFAULT_SCHEMA}', table_name='{CAR_TABLE_NAME}', column_name='{CAR_COLORS_COLUMN_NAME}', column_type=ColumnType.ARRAY)], enum_values_to_rename=[]) # ### end Alembic commands ###""" @@ -54,7 +54,7 @@ def test_add_new_enum_value_render_with_array(connection: "Connection"): assert ( template_args["downgrades"] == f"""# ### commands auto generated by Alembic - please adjust! ### - op.sync_enum_values('{DEFAULT_SCHEMA}', '{CAR_COLORS_ENUM_NAME}', [{', '.join(map(repr, old_enum_variants))}], # type: ignore[attr-defined] + op.sync_enum_values('{DEFAULT_SCHEMA}', '{CAR_COLORS_ENUM_NAME}', [{', '.join(map(repr, old_enum_variants))}], # type: ignore[attr-defined] [TableReference(table_schema='{DEFAULT_SCHEMA}', table_name='{CAR_TABLE_NAME}', column_name='{CAR_COLORS_COLUMN_NAME}', column_type=ColumnType.ARRAY)], enum_values_to_rename=[]) # ### end Alembic commands ###""" diff --git a/tests/sync_enum_values/test_render.py b/tests/sync_enum_values/test_render.py index 226dfeb..3acf069 100644 --- a/tests/sync_enum_values/test_render.py +++ b/tests/sync_enum_values/test_render.py @@ -45,7 +45,7 @@ def test_add_new_enum_value_render(connection: "Connection"): assert ( template_args["upgrades"] == f"""# ### commands auto generated by Alembic - please adjust! ### - op.sync_enum_values('{DEFAULT_SCHEMA}', '{USER_STATUS_ENUM_NAME}', [{', '.join(map(repr, new_enum_variants))}], # type: ignore[attr-defined] + op.sync_enum_values('{DEFAULT_SCHEMA}', '{USER_STATUS_ENUM_NAME}', [{', '.join(map(repr, new_enum_variants))}], # type: ignore[attr-defined] [TableReference(table_schema='{DEFAULT_SCHEMA}', table_name='{USER_TABLE_NAME}', column_name='{USER_STATUS_COLUMN_NAME}')], enum_values_to_rename=[]) # ### end Alembic commands ###""" @@ -53,7 +53,7 @@ def test_add_new_enum_value_render(connection: "Connection"): assert ( template_args["downgrades"] == f"""# ### commands auto generated by Alembic - please adjust! ### - op.sync_enum_values('{DEFAULT_SCHEMA}', '{USER_STATUS_ENUM_NAME}', [{', '.join(map(repr, old_enum_variants))}], # type: ignore[attr-defined] + op.sync_enum_values('{DEFAULT_SCHEMA}', '{USER_STATUS_ENUM_NAME}', [{', '.join(map(repr, old_enum_variants))}], # type: ignore[attr-defined] [TableReference(table_schema='{DEFAULT_SCHEMA}', table_name='{USER_TABLE_NAME}', column_name='{USER_STATUS_COLUMN_NAME}')], enum_values_to_rename=[]) # ### end Alembic commands ###""" @@ -207,7 +207,7 @@ class ExampleTable(Base): def get_expected_upgrade(self) -> str: return """ # ### commands auto generated by Alembic - please adjust! ### - op.sync_enum_values('public', 'my_enum', ['one', 'two', 'three', 'four'], # type: ignore[attr-defined] + op.sync_enum_values('public', 'my_enum', ['one', 'two', 'three', 'four'], # type: ignore[attr-defined] [TableReference(table_schema='public', table_name='example_table', column_name='enum_field', existing_server_default="'one'::my_enum")], enum_values_to_rename=[]) # ### end Alembic commands ### @@ -216,7 +216,7 @@ def get_expected_upgrade(self) -> str: def get_expected_downgrade(self) -> str: return """ # ### commands auto generated by Alembic - please adjust! ### - op.sync_enum_values('public', 'my_enum', ['one', 'two', 'three'], # type: ignore[attr-defined] + op.sync_enum_values('public', 'my_enum', ['one', 'two', 'three'], # type: ignore[attr-defined] [TableReference(table_schema='public', table_name='example_table', column_name='enum_field', existing_server_default="'one'::my_enum")], enum_values_to_rename=[]) # ### end Alembic commands ### diff --git a/tests/sync_enum_values/test_run_array_new_column.py b/tests/sync_enum_values/test_run_array_new_column.py index 5b0c60e..00f2aa3 100644 --- a/tests/sync_enum_values/test_run_array_new_column.py +++ b/tests/sync_enum_values/test_run_array_new_column.py @@ -63,7 +63,7 @@ def get_expected_upgrade(self) -> str: return """ # ### commands auto generated by Alembic - please adjust! ### op.add_column('a', sa.Column('value', postgresql.ARRAY(postgresql.ENUM('A', 'B', 'C', name='my_enum', create_type=False)), server_default=sa.text("ARRAY['A', 'B']::my_enum[]"), nullable=True)) - op.sync_enum_values('public', 'my_enum', ['A', 'B', 'C'], # type: ignore[attr-defined] + op.sync_enum_values('public', 'my_enum', ['A', 'B', 'C'], # type: ignore[attr-defined] [TableReference(table_schema='public', table_name='a', column_name='value', column_type=ColumnType.ARRAY, existing_server_default="ARRAY['A', 'B']::my_enum[]"), TableReference(table_schema='public', table_name='b', column_name='value', column_type=ColumnType.ARRAY, existing_server_default="ARRAY['A'::my_enum, 'B'::my_enum]")], enum_values_to_rename=[]) # ### end Alembic commands ### @@ -72,7 +72,7 @@ def get_expected_upgrade(self) -> str: def get_expected_downgrade(self) -> str: return """ # ### commands auto generated by Alembic - please adjust! ### - op.sync_enum_values('public', 'my_enum', ['A', 'B'], # type: ignore[attr-defined] + op.sync_enum_values('public', 'my_enum', ['A', 'B'], # type: ignore[attr-defined] [TableReference(table_schema='public', table_name='a', column_name='value', column_type=ColumnType.ARRAY, existing_server_default="ARRAY['A', 'B']::my_enum[]"), TableReference(table_schema='public', table_name='b', column_name='value', column_type=ColumnType.ARRAY, existing_server_default="ARRAY['A'::my_enum, 'B'::my_enum]")], enum_values_to_rename=[]) op.drop_column('a', 'value')