def test_motion_interface():
    """Test the motion module interface."""

    from pysteps.motion.constant import constant
    from pysteps.motion.darts import DARTS
    from pysteps.motion.lucaskanade import dense_lucaskanade
    from pysteps.motion.proesmans import proesmans
    from pysteps.motion.vet import vet

    method_getter = pysteps.motion.interface.get_method

    valid_names_func_pair = [
        ("constant", constant),
        ("darts", DARTS),
        ("lk", dense_lucaskanade),
        ("lucaskanade", dense_lucaskanade),
        ("proesmans", proesmans),
        ("vet", vet),
    ]

    invalid_names = ["dart", "pyvet", "lukascanade", "lucas-kanade", "no_method"]

    _generic_interface_test(method_getter, valid_names_func_pair, invalid_names)

    # Test default dummy method
    precip_field = method_getter(None)(numpy.random.random([2, 300, 500]))
    assert numpy.max(numpy.abs(precip_field)) == pytest.approx(0)

    # test not implemented names
    for name in ["brox", "clg"]:
        with pytest.raises(NotImplementedError):
            method_getter(name)  # last s missing
Test the motion module interface.
pysteps/tests/test_interfaces.py