Skip to content

Commit

Permalink
Fixup spaces count
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandrovRoman committed Aug 19, 2024
1 parent 3972704 commit 1fc379f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions tests/sync_enum_values/test_array_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ 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 ###"""
)
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 ###"""
Expand Down
8 changes: 4 additions & 4 deletions tests/sync_enum_values/test_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ 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 ###"""
)
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 ###"""
Expand Down Expand Up @@ -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 ###
Expand All @@ -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 ###
Expand Down
4 changes: 2 additions & 2 deletions tests/sync_enum_values/test_run_array_new_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
Expand All @@ -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')
Expand Down

0 comments on commit 1fc379f

Please sign in to comment.