Skip to content

Commit

Permalink
Trying to repair more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
goerch committed Nov 8, 2023
1 parent 21304e2 commit d485a68
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion flask_appbuilder/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ def __init__(
def convert(self):
for type_marker, field in self.conversion_table:
if getattr(self.datamodel, type_marker)(self.colname):
col_type = self.datamodel.list_columns[self.colname].type
# NOTE: this looks slightly questionable.
col_type = self.datamodel.list_columns[self.colname].type if type_marker not in ["is_string", "is_integer"] else None
return field(self, col_type)
log.error("Column %s Type not supported", self.colname)

Expand Down
14 changes: 7 additions & 7 deletions tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Boolean,
Date,
DateTime,
# Enum,
Enum,
Float,
Integer,
Numeric,
Expand All @@ -26,7 +26,7 @@

from flask import Flask
from flask_appbuilder.models.sqla.interface import SQLAInterface
# from flask_appbuilder.fields import EnumField
from flask_appbuilder.fields import EnumField
from flask_appbuilder.forms import GeneralModelConverter
from flask_appbuilder import Model

Expand All @@ -36,7 +36,7 @@ class FieldsModel(Model):
field_boolean = Column(Boolean())
field_date = Column(Date())
field_datetime = Column(DateTime())
# field_enum = Column(Enum())
field_enum = Column(Enum())
field_float = Column(Float())
field_integer = Column(Integer())
field_numeric_scale0 = Column(Numeric())
Expand All @@ -55,7 +55,7 @@ def test_model_without_context(self):
"field_boolean",
"field_date",
"field_datetime",
# "field_enum",
"field_enum",
"field_float",
"field_integer",
"field_numeric_scale0",
Expand All @@ -68,7 +68,7 @@ def test_model_without_context(self):
self.assertTrue(form.field_boolean.field_class is BooleanField)
self.assertTrue(form.field_date.field_class is DateField)
self.assertTrue(form.field_datetime.field_class is DateTimeField)
# self.assertTrue(form.field_enum.field_class is EnumField)
self.assertTrue(form.field_enum.field_class is EnumField)
self.assertTrue(form.field_float.field_class is FloatField)
self.assertTrue(form.field_integer.field_class is IntegerField)
self.assertTrue(form.field_numeric_scale0.field_class is DecimalField and not form.field_numeric_scale0.kwargs["places"])
Expand All @@ -84,7 +84,7 @@ def test_model_with_context(self):
"field_boolean",
"field_date",
"field_datetime",
# "field_enum",
"field_enum",
"field_float",
"field_integer",
"field_numeric_scale0",
Expand All @@ -101,7 +101,7 @@ def test_model_with_context(self):
self.assertTrue(isinstance(form.field_boolean, BooleanField))
self.assertTrue(isinstance(form.field_date, DateField))
self.assertTrue(isinstance(form.field_datetime, DateTimeField))
# self.assertTrue(isinstance(form.field_enum, EnumField))
self.assertTrue(isinstance(form.field_enum, EnumField))
self.assertTrue(isinstance(form.field_float, FloatField))
self.assertTrue(isinstance(form.field_integer, IntegerField))
self.assertTrue(isinstance(form.field_numeric_scale0, DecimalField) and not form.field_numeric_scale0.places)
Expand Down

0 comments on commit d485a68

Please sign in to comment.