Example #1
0
def test_param_schema_explicit():
    spec = load_spec(
        dict(
            id_name="x",
            name="x",
            category="Clean",
            parameters=[{"id_name": "whee", "type": "custom"}],
            param_schema={
                "id_name": {
                    "type": "dict",
                    "properties": {
                        "x": {"type": "integer"},
                        "y": {"type": "string", "default": "X"},
                    },
                }
            },
        )
    )

    assert spec.param_schema == ParamSchema.Dict(
        {
            "id_name": ParamSchema.Dict(
                {"x": ParamSchema.Integer(), "y": ParamSchema.String(default="X")}
            )
        }
    )
Example #2
0
 def test_clean_normal_dict(self):
     schema = ParamSchema.Dict({
         "str": ParamSchema.String(),
         "int": ParamSchema.Integer()
     })
     value = {"str": "foo", "int": 3}
     expected = dict(value)  # no-op
     result = self._call_clean_value(schema, value)
     self.assertEqual(result, expected)
Example #3
0
 def test_clean_normal_dict(self):
     input_shape = TableMetadata(3, [Column("A", ColumnType.Number())])
     schema = ParamSchema.Dict({
         "str": ParamSchema.String(),
         "int": ParamSchema.Integer()
     })
     value = {"str": "foo", "int": 3}
     expected = dict(value)  # no-op
     result = clean_value(schema, value, input_shape)
     self.assertEqual(result, expected)
 def test_validate_ok(self):
     S.Dict({"foo": S.String(default="FOO"), "bar": S.Integer(default=3)}).validate(
         {"foo": "FOO", "bar": 3}
     )
 def test_default(self):
     assert S.Dict(
         {"foo": S.String(default="FOO"), "bar": S.Integer(default=3)}
     ).default == {"foo": "FOO", "bar": 3}