コード例 #1
0
    def test_ui_available(self, mock_available, mock_atexit, mock_emit):
        """Register callbacks when the UI is available."""
        mock_available.return_value = True

        callbacks.register_callbacks()

        mock_atexit.assert_called_once()
        mock_emit.assert_called_once()
コード例 #2
0
    def test_no_ui(self, mock_available, mock_atexit, mock_emit):
        """Register callbacks when the UI is not available."""
        mock_available.return_value = False

        callbacks.register_callbacks()

        mock_atexit.assert_called_once()

        # _register_when_ui_available() will NOT be called when the UI is not available.
        mock_emit.assert_not_called()
コード例 #3
0
    def test_ui_available(self, mock_available, mock_register, mock_emit, mock_add):
        """Register callbacks when the UI is available."""
        mock_available.return_value = True

        callbacks.register_callbacks()

        mock_register.assert_called_with(callbacks._atexit_callback)

        mock_emit.assert_called_once()

        mock_add.assert_called_with(callbacks._hip_event_callback)
コード例 #4
0
    def test_no_ui(self, mock_available, mock_register, mock_emit, mock_add):
        """Register callbacks when the UI is not available."""
        mock_available.return_value = False

        callbacks.register_callbacks()

        mock_register.assert_called_with(callbacks._atexit_callback)

        # _register_when_ui_available() will NOT be called when the UI is not available.
        mock_emit.assert_not_called()

        mock_add.assert_called_with(callbacks._hip_event_callback)
コード例 #5
0
    def test_no_ui(self, mock_available, mock_register, mock_emit, mock_add):
        """Register callbacks when the UI is not available."""
        mock_available.return_value = False

        callbacks.register_callbacks()

        mock_register.assert_called_with(callbacks._atexit_callback)

        # _register_when_ui_available() will NOT be called when the UI is not available.
        mock_emit.assert_not_called()

        mock_add.assert_called_with(callbacks._hip_event_callback)
コード例 #6
0
    def test_ui_available(self, mock_available, mock_register, mock_emit,
                          mock_add):
        """Register callbacks when the UI is available."""
        mock_available.return_value = True

        callbacks.register_callbacks()

        mock_register.assert_called_with(callbacks._atexit_callback)

        mock_emit.assert_called_once()

        mock_add.assert_called_with(callbacks._hip_event_callback)
コード例 #7
0
    def test_ui_available(self, mocker):
        """Register callbacks when the UI is available."""
        mocker.patch("hou.isUIAvailable", return_value=True)
        mock_register = mocker.patch("ht.events.callbacks.atexit.register")
        mock_emit = mocker.patch(
            "ht.events.callbacks._register_when_ui_available")
        mock_add = mocker.patch(
            "ht.events.callbacks.hou.hipFile.addEventCallback")

        callbacks.register_callbacks()

        mock_register.assert_called_with(callbacks._atexit_callback)

        mock_emit.assert_called_once()

        mock_add.assert_called_with(callbacks._hip_event_callback)
コード例 #8
0
    def test_no_ui(self, mocker):
        """Register callbacks when the UI is not available."""
        mocker.patch("hou.isUIAvailable", return_value=False)
        mock_register = mocker.patch("ht.events.callbacks.atexit.register")
        mock_emit = mocker.patch(
            "ht.events.callbacks._register_when_ui_available")
        mock_add = mocker.patch(
            "ht.events.callbacks.hou.hipFile.addEventCallback")

        callbacks.register_callbacks()

        mock_register.assert_called_with(callbacks._atexit_callback)

        # _register_when_ui_available() will NOT be called when the UI is not available.
        mock_emit.assert_not_called()

        mock_add.assert_called_with(callbacks._hip_event_callback)
コード例 #9
0
def test_register_callbacks(mocker, ui_available):
    """Test ht.events.callbacks.register_callbacks."""
    mocker.patch("hou.isUIAvailable", return_value=ui_available)
    mock_register = mocker.patch("ht.events.callbacks.atexit.register")
    mock_emit = mocker.patch("ht.events.callbacks._register_when_ui_available")
    mock_add = mocker.patch("ht.events.callbacks.hou.hipFile.addEventCallback")

    callbacks.register_callbacks()

    mock_register.assert_called_with(callbacks._atexit_callback)

    if not ui_available:
        # _register_when_ui_available() will NOT be called when the UI is not available.
        mock_emit.assert_not_called()

    else:
        mock_emit.assert_called_once()

    mock_add.assert_called_with(callbacks._hip_event_callback)