Skip to content

Commit

Permalink
update test to support sqlalchemy inherit schema change
Browse files Browse the repository at this point in the history
Change-Id: Ie48d45c63442001aeaa6a81dc909af32af303aa2
  • Loading branch information
CaselIT committed Jan 4, 2025
1 parent 6bfca64 commit 8d13dc9
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions tests/test_autogen_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -1668,28 +1668,36 @@ def test_render_modify_nullable_w_default(self):
"existing_server_default='5')",
)

def _check_enum_inherit_schema(self, enum):
if enum.inherit_schema:
return enum, ", inherit_schema=True"
else:
return enum, ""

def test_render_enum(self):
enum, extra = self._check_enum_inherit_schema(
Enum("one", "two", "three", name="myenum")
)
eq_ignore_whitespace(
autogenerate.render._repr_type(
Enum("one", "two", "three", name="myenum"),
self.autogen_context,
),
"sa.Enum('one', 'two', 'three', name='myenum')",
autogenerate.render._repr_type(enum, self.autogen_context),
f"sa.Enum('one', 'two', 'three', name='myenum'{extra})",
)

enum, extra = self._check_enum_inherit_schema(
Enum("one", "two", "three")
)
eq_ignore_whitespace(
autogenerate.render._repr_type(
Enum("one", "two", "three"), self.autogen_context
),
"sa.Enum('one', 'two', 'three')",
autogenerate.render._repr_type(enum, self.autogen_context),
f"sa.Enum('one', 'two', 'three'{extra})",
)

def test_render_non_native_enum(self):
enum, extra = self._check_enum_inherit_schema(
Enum("one", "two", "three", native_enum=False)
)
eq_ignore_whitespace(
autogenerate.render._repr_type(
Enum("one", "two", "three", native_enum=False),
self.autogen_context,
),
"sa.Enum('one', 'two', 'three', native_enum=False)",
autogenerate.render._repr_type(enum, self.autogen_context),
f"sa.Enum('one', 'two', 'three'{extra}, native_enum=False)",
)

def test_repr_plain_sqla_type(self):
Expand Down

0 comments on commit 8d13dc9

Please sign in to comment.