Ejemplo n.º 1
0
class ChartDataFilterSchema(Schema):
    col = fields.Raw(
        description=
        "The column to filter by. Can be either a string (physical or "
        "saved expression) or an object (adhoc column)",
        required=True,
        example="country",
    )
    op = fields.String(  # pylint: disable=invalid-name
        description="The comparison operator.",
        validate=utils.OneOfCaseInsensitive(
            choices=[filter_op.value for filter_op in FilterOperator]),
        required=True,
        example="IN",
    )
    val = fields.Raw(
        description="The value or values to compare against. Can be a string, "
        "integer, decimal or list, depending on the operator.",
        example=["China", "France", "Japan"],
    )
    grain = fields.String(
        description="Optional time grain for temporal filters",
        example="PT1M",
    )
    isExtra = fields.Boolean(
        description=
        "Indicates if the filter has been added by a filter component as "
        "opposed to being a part of the original query.")
Ejemplo n.º 2
0
 def test_schema_one_of_case_insensitive(self):
     validator = schema.OneOfCaseInsensitive(choices=[1, 2, 3, "FoO", "BAR", "baz"])
     self.assertEqual(1, validator(1))
     self.assertEqual(2, validator(2))
     self.assertEqual("FoO", validator("FoO"))
     self.assertEqual("FOO", validator("FOO"))
     self.assertEqual("bar", validator("bar"))
     self.assertEqual("BaZ", validator("BaZ"))
     self.assertRaises(marshmallow.ValidationError, validator, "qwerty")
     self.assertRaises(marshmallow.ValidationError, validator, 4)
Ejemplo n.º 3
0
class ChartDataFilterSchema(Schema):
    col = fields.String(description="The column to filter.",
                        required=True,
                        example="country")
    op = fields.String(  # pylint: disable=invalid-name
        description="The comparison operator.",
        validate=utils.OneOfCaseInsensitive(
            choices=[filter_op.value for filter_op in FilterOperator]),
        required=True,
        example="IN",
    )
    val = fields.Raw(
        description="The value or values to compare against. Can be a string, "
        "integer, decimal or list, depending on the operator.",
        example=["China", "France", "Japan"],
    )