def test_given_field_name_when_correct_changes_field_and_returns_result( self): mood_factory = MoodAnalyserFactory() mood_object = mood_factory.return_mood_analyser_object( "mood_analyser", "MoodAnalyser") result_mood = mood_factory.change_fields_values( mood_object, "analyse_mood", "message", "I am in happy mood!") assert result_mood == "Happy"
def test_given_field_name_when_correct_but_value_to_none_throws_exception( self): mood_factory = MoodAnalyserFactory() mood_object = mood_factory.return_mood_analyser_object( "mood_analyser", "MoodAnalyser") with pytest.raises(MoodAnalyserError) as e: result_mood = mood_factory.change_fields_values( mood_object, "analyse_mood", "message", None) assert str(e.value) == "NULL_VALUE_EXCEPTION"
def test_given_field_name_when_incorrect_throws_exception(self): mood_factory = MoodAnalyserFactory() mood_object = mood_factory.return_mood_analyser_object( "mood_analyser", "MoodAnalyser") with pytest.raises(MoodAnalyserError) as e: result_mood = mood_factory.change_fields_values( mood_object, "analyse_mood", "WrongFieldName", "I am in happy mood!") assert str(e.value) == "NO_SUCH_FIELD_EXCEPTION"