diff --git a/tests/test_00_parasite/test_00_never.py b/tests/test_00_parasite/test_00_never.py index 0489747..1be6c1c 100644 --- a/tests/test_00_parasite/test_00_never.py +++ b/tests/test_00_parasite/test_00_never.py @@ -19,5 +19,5 @@ def test_never_default() -> None: def test_never_find() -> None: - assert p.never().find_and_parse_safe({}, "key") == Ok(Nil) - assert p.never().find_and_parse_safe({"key": "value"}, "key").is_err() + assert p.never()._find_and_parse_safe({}, "key") == Ok(Nil) + assert p.never()._find_and_parse_safe({"key": "value"}, "key").is_err() diff --git a/tests/test_00_parasite/test_01_any.py b/tests/test_00_parasite/test_01_any.py index 132e550..534844f 100644 --- a/tests/test_00_parasite/test_01_any.py +++ b/tests/test_00_parasite/test_01_any.py @@ -21,8 +21,8 @@ def test_any_default() -> None: def test_any_optional() -> None: - assert p.any().optional().find_and_parse_safe({}, "key") == Ok(Nil) - assert p.any().optional().find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) + assert p.any().optional()._find_and_parse_safe({}, "key") == Ok(Nil) + assert p.any().optional()._find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) - assert p.any().required().find_and_parse_safe({}, "key").is_err() - assert p.any().required().find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) + assert p.any().required()._find_and_parse_safe({}, "key").is_err() + assert p.any().required()._find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) diff --git a/tests/test_00_parasite/test_02_null.py b/tests/test_00_parasite/test_02_null.py index b08a63e..f89ec43 100644 --- a/tests/test_00_parasite/test_02_null.py +++ b/tests/test_00_parasite/test_02_null.py @@ -19,8 +19,8 @@ def test_null_default() -> None: def test_null_optional() -> None: - assert p.null().optional().find_and_parse_safe({}, "key") == Ok(Nil) - assert p.null().optional().find_and_parse_safe({"key": None}, "key") == Ok(Some(None)) + assert p.null().optional()._find_and_parse_safe({}, "key") == Ok(Nil) + assert p.null().optional()._find_and_parse_safe({"key": None}, "key") == Ok(Some(None)) - assert p.null().required().find_and_parse_safe({}, "key").is_err() - assert p.null().required().find_and_parse_safe({"key": None}, "key") == Ok(Some(None)) + assert p.null().required()._find_and_parse_safe({}, "key").is_err() + assert p.null().required()._find_and_parse_safe({"key": None}, "key") == Ok(Some(None)) diff --git a/tests/test_00_parasite/test_03_boolean.py b/tests/test_00_parasite/test_03_boolean.py index da42de6..5ec7a96 100644 --- a/tests/test_00_parasite/test_03_boolean.py +++ b/tests/test_00_parasite/test_03_boolean.py @@ -20,26 +20,26 @@ def test_boolean_default() -> None: def test_boolean_find() -> None: - assert p.boolean().find_and_parse_safe({}, "key").is_err() - assert p.boolean().find_and_parse_safe({"key": True}, "key") == Ok(Some(True)) + assert p.boolean()._find_and_parse_safe({}, "key").is_err() + assert p.boolean()._find_and_parse_safe({"key": True}, "key") == Ok(Some(True)) def test_boolean_optional() -> None: - assert p.boolean().optional().find_and_parse_safe({}, "key") == Ok(Nil) - assert p.boolean().optional().find_and_parse_safe({"key": True}, "key") == Ok(Some(True)) + assert p.boolean().optional()._find_and_parse_safe({}, "key") == Ok(Nil) + assert p.boolean().optional()._find_and_parse_safe({"key": True}, "key") == Ok(Some(True)) - assert p.boolean().required().find_and_parse_safe({}, "key").is_err() - assert p.boolean().required().find_and_parse_safe({"key": True}, "key") == Ok(Some(True)) + assert p.boolean().required()._find_and_parse_safe({}, "key").is_err() + assert p.boolean().required()._find_and_parse_safe({"key": True}, "key") == Ok(Some(True)) def test_boolean_nullable() -> None: - assert p.boolean().nullable().find_and_parse_safe({}, "key").is_err() - assert p.boolean().nullable().find_and_parse_safe({"key": True}, "key") == Ok(Some(True)) - assert p.boolean().nullable().find_and_parse_safe({"key": None}, "key") == Ok(Some(None)) + assert p.boolean().nullable()._find_and_parse_safe({}, "key").is_err() + assert p.boolean().nullable()._find_and_parse_safe({"key": True}, "key") == Ok(Some(True)) + assert p.boolean().nullable()._find_and_parse_safe({"key": None}, "key") == Ok(Some(None)) - assert p.boolean().non_nullable().find_and_parse_safe({}, "key").is_err() - assert p.boolean().non_nullable().find_and_parse_safe({"key": True}, "key") == Ok(Some(True)) - assert p.boolean().non_nullable().find_and_parse_safe({"key": None}, "key").is_err() + assert p.boolean().non_nullable()._find_and_parse_safe({}, "key").is_err() + assert p.boolean().non_nullable()._find_and_parse_safe({"key": True}, "key") == Ok(Some(True)) + assert p.boolean().non_nullable()._find_and_parse_safe({"key": None}, "key").is_err() def test_boolean_leaniant() -> None: diff --git a/tests/test_00_parasite/test_04_number.py b/tests/test_00_parasite/test_04_number.py index 6119f97..d1ec783 100644 --- a/tests/test_00_parasite/test_04_number.py +++ b/tests/test_00_parasite/test_04_number.py @@ -20,31 +20,31 @@ def test_number_default() -> None: def test_number_find() -> None: - assert p.number().find_and_parse_safe({}, "key").is_err() - assert p.number().find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) - assert p.number().find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) + assert p.number()._find_and_parse_safe({}, "key").is_err() + assert p.number()._find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) + assert p.number()._find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) def test_number_optional() -> None: - assert p.number().optional().find_and_parse_safe({}, "key") == Ok(Nil) - assert p.number().optional().find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) - assert p.number().optional().find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) + assert p.number().optional()._find_and_parse_safe({}, "key") == Ok(Nil) + assert p.number().optional()._find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) + assert p.number().optional()._find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) - assert p.number().required().find_and_parse_safe({}, "key").is_err() - assert p.number().required().find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) - assert p.number().required().find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) + assert p.number().required()._find_and_parse_safe({}, "key").is_err() + assert p.number().required()._find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) + assert p.number().required()._find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) def test_number_nullable() -> None: - assert p.number().nullable().find_and_parse_safe({}, "key").is_err() - assert p.number().nullable().find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) - assert p.number().nullable().find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) - assert p.number().nullable().find_and_parse_safe({"key": None}, "key") == Ok(Some(None)) - - assert p.number().non_nullable().find_and_parse_safe({}, "key").is_err() - assert p.number().non_nullable().find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) - assert p.number().non_nullable().find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) - assert p.number().non_nullable().find_and_parse_safe({"key": None}, "key").is_err() + assert p.number().nullable()._find_and_parse_safe({}, "key").is_err() + assert p.number().nullable()._find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) + assert p.number().nullable()._find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) + assert p.number().nullable()._find_and_parse_safe({"key": None}, "key") == Ok(Some(None)) + + assert p.number().non_nullable()._find_and_parse_safe({}, "key").is_err() + assert p.number().non_nullable()._find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) + assert p.number().non_nullable()._find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) + assert p.number().non_nullable()._find_and_parse_safe({"key": None}, "key").is_err() def test_number_integer() -> None: diff --git a/tests/test_00_parasite/test_05_string.py b/tests/test_00_parasite/test_05_string.py index 7f215d9..b886e22 100644 --- a/tests/test_00_parasite/test_05_string.py +++ b/tests/test_00_parasite/test_05_string.py @@ -21,27 +21,27 @@ def test_string_default() -> None: def test_string_find() -> None: - assert p.string().find_and_parse_safe({}, "key").is_err() - assert p.string().find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) + assert p.string()._find_and_parse_safe({}, "key").is_err() + assert p.string()._find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) def test_string_optional() -> None: - assert p.string().optional().find_and_parse_safe({}, "key") == Ok(Nil) - assert p.string().optional().find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) + assert p.string().optional()._find_and_parse_safe({}, "key") == Ok(Nil) + assert p.string().optional()._find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) - assert p.string().required().find_and_parse_safe({}, "key").is_err() - assert p.string().required().find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) + assert p.string().required()._find_and_parse_safe({}, "key").is_err() + assert p.string().required()._find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) def test_string_nullable() -> None: - assert p.string().nullable().find_and_parse_safe({}, "key").is_err() - assert p.string().nullable().find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) - assert p.string().nullable().find_and_parse_safe({"key": None}, "key") == Ok(Some(None)) - - assert p.string().non_nullable().find_and_parse_safe({}, "key").is_err() - assert p.string().non_nullable().find_and_parse_safe({"key": "value"}, - "key") == Ok(Some("value")) - assert p.string().non_nullable().find_and_parse_safe({"key": None}, "key").is_err() + assert p.string().nullable()._find_and_parse_safe({}, "key").is_err() + assert p.string().nullable()._find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) + assert p.string().nullable()._find_and_parse_safe({"key": None}, "key") == Ok(Some(None)) + + assert p.string().non_nullable()._find_and_parse_safe({}, "key").is_err() + assert p.string().non_nullable()._find_and_parse_safe({"key": "value"}, + "key") == Ok(Some("value")) + assert p.string().non_nullable()._find_and_parse_safe({"key": None}, "key").is_err() def test_string_trim() -> None: diff --git a/tests/test_00_parasite/test_06_variant.py b/tests/test_00_parasite/test_06_variant.py index f0f60dc..8e082ac 100644 --- a/tests/test_00_parasite/test_06_variant.py +++ b/tests/test_00_parasite/test_06_variant.py @@ -39,40 +39,40 @@ def test_variant_add_variant() -> None: def test_variant_find() -> None: v = p.variant().add_variant(p.number()).add_variant(p.string()) - assert v.find_and_parse_safe({}, "key").is_err() - assert v.find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) - assert v.find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) - assert v.find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) + assert v._find_and_parse_safe({}, "key").is_err() + assert v._find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) + assert v._find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) + assert v._find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) def test_variant_optional() -> None: v = p.variant().add_variant(p.number()).add_variant(p.string()) - assert v.optional().find_and_parse_safe({}, "key") == Ok(Nil) - assert v.optional().find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) - assert v.optional().find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) - assert v.optional().find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) + assert v.optional()._find_and_parse_safe({}, "key") == Ok(Nil) + assert v.optional()._find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) + assert v.optional()._find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) + assert v.optional()._find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) - assert v.required().find_and_parse_safe({}, "key").is_err() - assert v.required().find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) - assert v.required().find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) - assert v.required().find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) + assert v.required()._find_and_parse_safe({}, "key").is_err() + assert v.required()._find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) + assert v.required()._find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) + assert v.required()._find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) def test_variant_nullable() -> None: v = p.variant().add_variant(p.number()).add_variant(p.string()) - assert v.nullable().find_and_parse_safe({}, "key").is_err() - assert v.nullable().find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) - assert v.nullable().find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) - assert v.nullable().find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) - assert v.nullable().find_and_parse_safe({"key": None}, "key") == Ok(Some(None)) - - assert v.non_nullable().find_and_parse_safe({}, "key").is_err() - assert v.non_nullable().find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) - assert v.non_nullable().find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) - assert v.non_nullable().find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) - assert v.non_nullable().find_and_parse_safe({"key": None}, "key").is_err() + assert v.nullable()._find_and_parse_safe({}, "key").is_err() + assert v.nullable()._find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) + assert v.nullable()._find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) + assert v.nullable()._find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) + assert v.nullable()._find_and_parse_safe({"key": None}, "key") == Ok(Some(None)) + + assert v.non_nullable()._find_and_parse_safe({}, "key").is_err() + assert v.non_nullable()._find_and_parse_safe({"key": 1}, "key") == Ok(Some(1)) + assert v.non_nullable()._find_and_parse_safe({"key": 1.0}, "key") == Ok(Some(1.0)) + assert v.non_nullable()._find_and_parse_safe({"key": "value"}, "key") == Ok(Some("value")) + assert v.non_nullable()._find_and_parse_safe({"key": None}, "key").is_err() def test_variant_rm_variant() -> None: diff --git a/tests/test_00_parasite/test_07_array.py b/tests/test_00_parasite/test_07_array.py index e2de6a8..da83068 100644 --- a/tests/test_00_parasite/test_07_array.py +++ b/tests/test_00_parasite/test_07_array.py @@ -27,37 +27,37 @@ def test_array_default() -> None: def test_array_find() -> None: - assert p.array().find_and_parse_safe({}, "key").is_err() - assert p.array().find_and_parse_safe({"key": []}, "key") == Ok(Some([])) + assert p.array()._find_and_parse_safe({}, "key").is_err() + assert p.array()._find_and_parse_safe({"key": []}, "key") == Ok(Some([])) - assert p.array().find_and_parse_safe({"key": [1, 2, 3]}, "key") == Ok(Some([1, 2, 3])) - assert p.array().find_and_parse_safe({"key": [1.0, 2.0, 3.0]}, - "key") == Ok(Some([1.0, 2.0, 3.0])) - assert p.array().find_and_parse_safe({"key": ["hello", "world"]}, - "key") == Ok(Some(["hello", "world"])) - assert p.array().find_and_parse_safe({"key": [True, False]}, "key") == Ok(Some([True, False])) - assert p.array().find_and_parse_safe({"key": [[], {}]}, "key") == Ok(Some([[], {}])) - assert p.array().find_and_parse_safe({"key": [(), set()]}, "key") == Ok(Some([(), set()])) - assert p.array().find_and_parse_safe({"key": [set(), frozenset()]}, - "key") == Ok(Some([set(), frozenset()])) + assert p.array()._find_and_parse_safe({"key": [1, 2, 3]}, "key") == Ok(Some([1, 2, 3])) + assert p.array()._find_and_parse_safe({"key": [1.0, 2.0, 3.0]}, + "key") == Ok(Some([1.0, 2.0, 3.0])) + assert p.array()._find_and_parse_safe({"key": ["hello", "world"]}, + "key") == Ok(Some(["hello", "world"])) + assert p.array()._find_and_parse_safe({"key": [True, False]}, "key") == Ok(Some([True, False])) + assert p.array()._find_and_parse_safe({"key": [[], {}]}, "key") == Ok(Some([[], {}])) + assert p.array()._find_and_parse_safe({"key": [(), set()]}, "key") == Ok(Some([(), set()])) + assert p.array()._find_and_parse_safe({"key": [set(), frozenset()]}, + "key") == Ok(Some([set(), frozenset()])) def test_array_optional() -> None: - assert p.array().optional().find_and_parse_safe({}, "key") == Ok(Nil) - assert p.array().optional().find_and_parse_safe({"key": []}, "key") == Ok(Some([])) + assert p.array().optional()._find_and_parse_safe({}, "key") == Ok(Nil) + assert p.array().optional()._find_and_parse_safe({"key": []}, "key") == Ok(Some([])) - assert p.array().required().find_and_parse_safe({}, "key").is_err() - assert p.array().required().find_and_parse_safe({"key": []}, "key") == Ok(Some([])) + assert p.array().required()._find_and_parse_safe({}, "key").is_err() + assert p.array().required()._find_and_parse_safe({"key": []}, "key") == Ok(Some([])) def test_array_nullable() -> None: - assert p.array().nullable().find_and_parse_safe({}, "key").is_err() - assert p.array().nullable().find_and_parse_safe({"key": []}, "key") == Ok(Some([])) - assert p.array().nullable().find_and_parse_safe({"key": None}, "key") == Ok(Some(None)) + assert p.array().nullable()._find_and_parse_safe({}, "key").is_err() + assert p.array().nullable()._find_and_parse_safe({"key": []}, "key") == Ok(Some([])) + assert p.array().nullable()._find_and_parse_safe({"key": None}, "key") == Ok(Some(None)) - assert p.array().non_nullable().find_and_parse_safe({}, "key").is_err() - assert p.array().non_nullable().find_and_parse_safe({"key": []}, "key") == Ok(Some([])) - assert p.array().non_nullable().find_and_parse_safe({"key": None}, "key").is_err() + assert p.array().non_nullable()._find_and_parse_safe({}, "key").is_err() + assert p.array().non_nullable()._find_and_parse_safe({"key": []}, "key") == Ok(Some([])) + assert p.array().non_nullable()._find_and_parse_safe({"key": None}, "key").is_err() def test_array_min() -> None: diff --git a/tests/test_00_parasite/test_08_object.py b/tests/test_00_parasite/test_08_object.py index 4b5baaa..c844626 100644 --- a/tests/test_00_parasite/test_08_object.py +++ b/tests/test_00_parasite/test_08_object.py @@ -29,26 +29,26 @@ def test_object_default() -> None: def test_object_find() -> None: - assert p.obj().find_and_parse_safe({}, "key").is_err() - assert p.obj().find_and_parse_safe({"key": {}}, "key") == Ok(Some({})) + assert p.obj()._find_and_parse_safe({}, "key").is_err() + assert p.obj()._find_and_parse_safe({"key": {}}, "key") == Ok(Some({})) def test_object_optional() -> None: - assert p.obj().optional().find_and_parse_safe({}, "key") == Ok(Nil) - assert p.obj().optional().find_and_parse_safe({"key": {}}, "key") == Ok(Some({})) + assert p.obj().optional()._find_and_parse_safe({}, "key") == Ok(Nil) + assert p.obj().optional()._find_and_parse_safe({"key": {}}, "key") == Ok(Some({})) - assert p.obj().required().find_and_parse_safe({}, "key").is_err() - assert p.obj().required().find_and_parse_safe({"key": {}}, "key") == Ok(Some({})) + assert p.obj().required()._find_and_parse_safe({}, "key").is_err() + assert p.obj().required()._find_and_parse_safe({"key": {}}, "key") == Ok(Some({})) def test_object_nullable() -> None: - assert p.obj().nullable().find_and_parse_safe({}, "key").is_err() - assert p.obj().nullable().find_and_parse_safe({"key": {}}, "key") == Ok(Some({})) - assert p.obj().nullable().find_and_parse_safe({"key": None}, "key") == Ok(Some(None)) + assert p.obj().nullable()._find_and_parse_safe({}, "key").is_err() + assert p.obj().nullable()._find_and_parse_safe({"key": {}}, "key") == Ok(Some({})) + assert p.obj().nullable()._find_and_parse_safe({"key": None}, "key") == Ok(Some(None)) - assert p.obj().non_nullable().find_and_parse_safe({}, "key").is_err() - assert p.obj().non_nullable().find_and_parse_safe({"key": {}}, "key") == Ok(Some({})) - assert p.obj().non_nullable().find_and_parse_safe({"key": None}, "key").is_err() + assert p.obj().non_nullable()._find_and_parse_safe({}, "key").is_err() + assert p.obj().non_nullable()._find_and_parse_safe({"key": {}}, "key") == Ok(Some({})) + assert p.obj().non_nullable()._find_and_parse_safe({"key": None}, "key").is_err() def test_object_init_items() -> None: