Import upstream snapshot c19f713c415a699a79d71cd96aa13c3104a05047
nightly / Test against latest dependencies (py3.10) (push) Has been cancelled
nightly / Test against latest dependencies (py3.13) (push) Has been cancelled
tests / tests (3.13, locked) (push) Has been cancelled
tests / tests (3.13, unlocked) (push) Has been cancelled
tests / pyright (3.10) (push) Has been cancelled
tests / lint-format (push) Has been cancelled
tests / tests (3.10, locked) (push) Has been cancelled
tests / tests (3.11, locked) (push) Has been cancelled
tests / tests (3.12, locked) (push) Has been cancelled
tests / pyright (3.11) (push) Has been cancelled
tests / pyright (3.12) (push) Has been cancelled
tests / pyright (3.13) (push) Has been cancelled
tests / ty-check (3.10) (push) Has been cancelled
tests / ty-check (3.11) (push) Has been cancelled
tests / ty-check (3.12) (push) Has been cancelled
tests / ty-check (3.13) (push) Has been cancelled
tests / stubs (push) Has been cancelled
tests / smoke-test (push) Has been cancelled
Docker / check_paths (push) Has been cancelled
Docker / build (push) Has been cancelled
docs / build (push) Has been cancelled
nightly / Test against latest dependencies (py3.10) (push) Has been cancelled
nightly / Test against latest dependencies (py3.13) (push) Has been cancelled
tests / tests (3.13, locked) (push) Has been cancelled
tests / tests (3.13, unlocked) (push) Has been cancelled
tests / pyright (3.10) (push) Has been cancelled
tests / lint-format (push) Has been cancelled
tests / tests (3.10, locked) (push) Has been cancelled
tests / tests (3.11, locked) (push) Has been cancelled
tests / tests (3.12, locked) (push) Has been cancelled
tests / pyright (3.11) (push) Has been cancelled
tests / pyright (3.12) (push) Has been cancelled
tests / pyright (3.13) (push) Has been cancelled
tests / ty-check (3.10) (push) Has been cancelled
tests / ty-check (3.11) (push) Has been cancelled
tests / ty-check (3.12) (push) Has been cancelled
tests / ty-check (3.13) (push) Has been cancelled
tests / stubs (push) Has been cancelled
tests / smoke-test (push) Has been cancelled
Docker / check_paths (push) Has been cancelled
Docker / build (push) Has been cancelled
docs / build (push) Has been cancelled
Upstream: https://github.com/michaelgillett/mjlab Upstream-Commit: c19f713c415a699a79d71cd96aa13c3104a05047 Upstream-Branch: main
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"""Tests for native viewer custom action dispatch."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from mjlab.viewer.base import ViewerAction
|
||||
from mjlab.viewer.native.viewer import NativeMujocoViewer
|
||||
|
||||
|
||||
def _make_viewer(num_envs: int = 3) -> NativeMujocoViewer:
|
||||
env = MagicMock()
|
||||
env.cfg.viewer.env_idx = 0
|
||||
env.unwrapped.num_envs = num_envs
|
||||
return NativeMujocoViewer(env, MagicMock())
|
||||
|
||||
|
||||
def test_toggle_actions_dispatch_by_action_enum():
|
||||
v = _make_viewer()
|
||||
|
||||
assert not v._show_plots
|
||||
assert v._handle_custom_action(ViewerAction.TOGGLE_PLOTS, None)
|
||||
assert v._show_plots
|
||||
|
||||
assert v._show_debug_vis
|
||||
assert v._handle_custom_action(ViewerAction.TOGGLE_DEBUG_VIS, None)
|
||||
assert not v._show_debug_vis
|
||||
|
||||
assert not v._show_all_envs
|
||||
assert v._handle_custom_action(ViewerAction.TOGGLE_SHOW_ALL_ENVS, None)
|
||||
assert v._show_all_envs
|
||||
|
||||
|
||||
def test_prev_next_env_actions_wrap_and_succeed():
|
||||
v = _make_viewer(num_envs=3)
|
||||
v.env_idx = 0
|
||||
assert v._handle_custom_action(ViewerAction.PREV_ENV, None)
|
||||
assert v.env_idx == 2
|
||||
assert v._handle_custom_action(ViewerAction.NEXT_ENV, None)
|
||||
assert v.env_idx == 0
|
||||
Reference in New Issue
Block a user