Esempio n. 1
0
 def check_client_set_attr(x):
     mock_client.set_attr.assert_called_with(
         sim_name=sim_name,
         attr_ref=AttributeRef(entity_id=1,
                               component="position",
                               attribute="y"),
         value=wrap(x),
     )
Esempio n. 2
0
 def set_attr(self, name: str, value: Any):
     # set attribute to value on the engine
     self._client.set_attr(
         sim_name=self._sim_name,
         attr_ref=AttributeRef(
             entity_id=self._entity_id,
             component=self._name,
             attribute=name,
         ),
         value=wrap(value),
     )
Esempio n. 3
0
def wrap_const(val: Any):
    """Wrap the given native value as a Constant graph node.
    If val is a Constant node, returns value as is.
    Args:
        val: Native value to wrap.
    Returns:
        The given value wrapped as a constant graph node.
    """
    # check if already constant node, return as is if true.
    if isinstance(val, Node) and val.WhichOneof("op") == "const_op":
        return val
    return Node(const_op=Node.Const(held_value=wrap(val)))
Esempio n. 4
0
def mock_client():
    mock_client = Mock(spec=Client)
    mock_client.get_attr.return_value = wrap(3.2)
    return mock_client
Esempio n. 5
0
def attr_val():
    return wrap(0.314)