def test_calculate_band_confidence_score_is_non_negative(): mastery_score, score, attempts = 0.7, -1., 1. try: algorithm._calculate_band_confidence(mastery_score, score, attempts) assert False except Exception as error: assert error.__class__.__name__ == 'ValueError' assert str(error) == f"{score} < 0 : score should be non-negative"
def test_calculate_band_confidence_score_lt_attempts(): mastery_score, score, attempts = 0.7, 2., 1. try: algorithm._calculate_band_confidence(mastery_score, score, attempts) assert False except Exception as error: assert error.__class__.__name__ == 'ValueError' assert str( error ) == f"{score} > {attempts} : score should be less than or equal to attempts"
def test_calculate_band_confidence_attempts_is_float(): mastery_score, score, attempts = 0.7, 1., 1 try: algorithm._calculate_band_confidence(mastery_score, score, attempts) assert False except Exception as error: assert error.__class__.__name__ == 'TypeError' assert str( error ) == f"attempts should be a float, a {attempts.__class__.__name__} was provided"
def test_calculate_band_confidence_mastery_score_in_0_to_1(): mastery_score, score, attempts = -0.7, 1., 1. try: algorithm._calculate_band_confidence(mastery_score, score, attempts) assert False except Exception as error: assert error.__class__.__name__ == 'ValueError' assert str( error ) == f"unexpected value encountered : mastery_score should be in the interval [0, 1]" mastery_score, score, attempts = 7., 1., 1. try: algorithm._calculate_band_confidence(mastery_score, score, attempts) assert False except Exception as error: assert error.__class__.__name__ == 'ValueError' assert str( error ) == f"unexpected value encountered : mastery_score should be in the interval [0, 1]"
def test_calculate_band_confidence_in_range_0_to_1(): confidence = algorithm._calculate_band_confidence(0.5, 1., 2.) assert confidence == pytest.approx(0.5, abs=0.5)
def test_calculate_band_confidence_returns_float(): confidence = algorithm._calculate_band_confidence(0.5, 1., 2.) assert isinstance(confidence, float)