Skip to content
Snippets Groups Projects
Verified Commit b835e687 authored by Anton Tetov Johansson's avatar Anton Tetov Johansson
Browse files

fixed kwargs

parent 17a6b103
Branches
Tags
No related merge requests found
Pipeline #1699 failed
from collections import OrderedDict
from random import random
import pytest
from ur_py_ctl.urscript_commands import _add_whitespace
from ur_py_ctl.urscript_commands import _get_conf
from ur_py_ctl.urscript_commands import _get_func
from ur_py_ctl.urscript_commands import _get_pose
from ur_py_ctl.urscript_commands import move_to_conf
@pytest.fixture()
......@@ -26,6 +30,25 @@ def pose_str():
return "p[22.00000, 13.00000, 25.00000, 3.14000, 0.00000, 1.70000]"
@pytest.fixture()
def kwargs_input_output():
input_ = OrderedDict(
{
"v": random() * 2,
"a": random() * 0.1,
"t": random() * 3,
"r": random() * 0.2,
}
)
output = OrderedDict()
for key, value in input_.items():
output[key] = f"{key}={value:.5f}"
return input_, output
def test__add_whitespace():
def func(input_):
return input_[::-1]
......@@ -58,3 +81,23 @@ def test__get_conf(conf_list, conf_str):
def test__get_pose(pose_list, pose_str):
assert _get_pose(*pose_list) == pose_str
def test_move_to_conf(conf_list, conf_str):
ur_func = move_to_conf(conf_list)
assert ur_func == f"\tmovej({conf_str})\n"
def test_move_to_conf_kwargs(conf_list, conf_str, kwargs_input_output):
input_kwargs, output_kwargs = kwargs_input_output
ur_func = move_to_conf(conf_list, **input_kwargs)
assert ur_func == f"\tmovej({conf_str}, {', '.join(output_kwargs.values())})\n"
ur_func = move_to_conf(conf_list, v=input_kwargs["v"], t=input_kwargs["t"])
assert (
ur_func == f"\tmovej({conf_str}, {output_kwargs['v']}, {output_kwargs['t']})\n"
)
......@@ -46,7 +46,7 @@ def _get_move_kwargs(**kwargs) -> str:
if len(urscript_kwargs) == 0:
return ""
else:
return " ,".join(kwargs)
return ", ".join(urscript_kwargs)
class Motion(object):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment