def test__check_proposals_proposals_gt_cardinality(self): """Test that ``ValueError`` is being raised if ``proposals`` is greater than ``self.tunable.cardinality``. """ # setup instance = MagicMock() instance.tunable.cardinality = 4 # run / assert with self.assertRaises(ValueError): BaseTuner._check_proposals(instance, 5)
def test__check_proposals_trials_and_proposals_gt_cardinality(self): """Test that ``ValueError`` is being raised if ``proposals`` + ``len(self.trials)`` is greater than ``self.tunable.cardinality``. """ # setup instance = MagicMock() instance.tunable.cardinality = 4 instance._trials_set.__len__.return_value = 2 # run / assert with self.assertRaises(ValueError): BaseTuner._check_proposals(instance, 3)
def test__check_proposals_trials_eq_cardinality(self): """Test that ``ValueError`` is being raised if ``self.trials`` is equal to ``self.tunable.cardinality``. """ # setup instance = MagicMock() instance.tunable.cardinality = 2 instance._trials_set.__len__.return_value = 2 # run / assert with self.assertRaises(ValueError): BaseTuner._check_proposals(instance, 1)
def test__check_proposals_not_raise(self): """Test that ``ValueError`` is not being raised.""" # setup instance = MagicMock() instance.tunable.cardinality = 4 instance._trials_set.__len__.return_value = 2 # run / assert result = BaseTuner._check_proposals(instance, 1) assert result is None