Ejemplo n.º 1
0
    def test_propose_many_values_no_duplicates(self, mock__check_proposals):
        """Test that ``propose`` method calls it's child implemented method with more than one
        proposals and ``allow_duplicates`` as ``False``.
        """
        # setup
        instance = MagicMock()
        inverse_return = instance.tunable.inverse_transform.return_value
        inverse_return.to_dict.return_value = [1, 2]
        instance._propose = MagicMock(return_value=2)

        # run
        result = BaseTuner.propose(instance, 2)

        # assert
        instance._propose.assert_called_once_with(2, False)
        instance.tunable.inverse_transform.called_once_with(2)
        inverse_return.to_dict.assert_called_once_with(orient='records')
        assert result == [1, 2]
Ejemplo n.º 2
0
    def test_propose_one_value_allow_duplicates(self, mock__check_proposals):
        """Test that ``propose`` method calls it's child implemented method with
        ``allow_duplicates`` as ``True``.
        """
        # setup
        instance = MagicMock()
        inverse_return = instance.tunable.inverse_transform.return_value
        inverse_return.to_dict.return_value = [1]
        instance._propose = MagicMock(return_value=1)

        # run
        result = BaseTuner.propose(instance, 1, allow_duplicates=True)

        # assert
        instance._check_proposals.assert_not_called()
        instance._propose.assert_called_once_with(1, True)
        instance.tunable.inverse_transform.called_once_with(1)
        inverse_return.to_dict.assert_called_once_with(orient='records')
        assert result == 1