Skip to content

Commit

Permalink
test for enums
Browse files Browse the repository at this point in the history
  • Loading branch information
daimor committed May 2, 2023
1 parent 5eb62b0 commit f2a36eb
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/test_suite.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from enum import Enum

from sqlalchemy.testing.suite import FetchLimitOffsetTest as _FetchLimitOffsetTest
from sqlalchemy.testing.suite import CompoundSelectTest as _CompoundSelectTest
from sqlalchemy.testing.suite import CTETest as _CTETest
Expand Down Expand Up @@ -187,3 +189,41 @@ def test_expect_bytes(self):
select(self.tables.data),
[(b"test", b"test")],
)


class SomeType(str, Enum):
FIRST = "first value"
SECOND = "second value"


class IRISEnumTest(fixtures.TablesTest):
__backend__ = True

@classmethod
def define_tables(cls, metadata):
Table(
"data",
metadata,
Column("val", String(50)),
)

@classmethod
def insert_data(cls, connection):
connection.execute(
cls.tables.data.insert(),
[
{"val": SomeType.FIRST},
{"val": SomeType.SECOND},
{"val": None},
],
)

def _assert_result(self, select, result):
with config.db.connect() as conn:
eq_(conn.execute(select).fetchall(), result)

def test_expect_bytes(self):
self._assert_result(
select(self.tables.data),
[(SomeType.FIRST,), (SomeType.SECOND,), (None,)],
)

0 comments on commit f2a36eb

Please sign in to comment.