Fix enum schema (#715)
* fix schema with enum fields - issue #699 * fix drivers dependencies - make them optional * fix command * provide extras * add bolean field to related model * add test with select related and boolean * new test case based on issue * fix bool issue in postgres limit queries - issue #704 * fix coverage * bump version and add release info
This commit is contained in:
33
tests/test_fastapi/test_enum_schema.py
Normal file
33
tests/test_fastapi/test_enum_schema.py
Normal file
@ -0,0 +1,33 @@
|
||||
from enum import Enum
|
||||
|
||||
import databases
|
||||
import sqlalchemy
|
||||
|
||||
import ormar
|
||||
from tests.settings import DATABASE_URL
|
||||
|
||||
database = databases.Database(DATABASE_URL, force_rollback=True)
|
||||
metadata = sqlalchemy.MetaData()
|
||||
|
||||
|
||||
class MyEnum(Enum):
|
||||
SMALL = 1
|
||||
BIG = 2
|
||||
|
||||
|
||||
class EnumExample(ormar.Model):
|
||||
class Meta:
|
||||
tablename = "enum_example"
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
size: MyEnum = ormar.Enum(enum_class=MyEnum, default=MyEnum.SMALL)
|
||||
|
||||
|
||||
def test_proper_schema():
|
||||
schema = EnumExample.schema_json()
|
||||
assert (
|
||||
'{"MyEnum": {"title": "MyEnum", "description": "An enumeration.", '
|
||||
'"enum": [1, 2]}}' in schema
|
||||
)
|
||||
Reference in New Issue
Block a user