def test_given_moodanalyser_class_with_parameters_when_corect_returns_object(
         self):
     mood = MoodAnalyserFactory()
     mood_object = MoodAnalyser()
     assert mood_object.equals(
         mood.return_mood_analyser_object("mood_analyser", "MoodAnalyser",
                                          "I am in happy mood"))
 def test_given_package_when_incorect_throws_exception(self):
     with pytest.raises(MoodAnalyserError) as e:
         mood = MoodAnalyserFactory()
         mood_object = MoodAnalyser()
         assert mood_object.equals(
             mood.return_mood_analyser_object("Incorrect Class",
                                              "MoodAnalyser"))
     assert str(e.value) == "INVALID_CLASS_OR_PACKAGE_EXCEPTION"
def test_analysemood_whengivenmessage_sad_shouldreturn_sad():
    moodAnalyser = MoodAnalyser("Iam in Sad Mood")
    mood = moodAnalyser.analysemood()
    assert mood == "SAD"
def test_analysemood_whengivenemptymessage_shouldreturn_exception():
    try:
        moodAnalyser = MoodAnalyser("")
        moodAnalyser.analysemood()
    except MoodAnalyserException as e:
        assert e.message == "Entered Empty Value"
def test_analysemood_whengivennullmessage_shouldreturn_exception():
    try:
        moodAnalyser = MoodAnalyser(None)
        moodAnalyser.analysemood()
    except MoodAnalyserException as e:
        assert e.type == TypeError
def test_analysemood_whengivenmessage_happy_shouldreturn_happy():
    moodAnalyser = MoodAnalyser("Iam in Happy Mood")
    mood = moodAnalyser.analysemood()
    assert mood == "HAPPY"
Example #7
0
 def test_passed_given_none_message_to_constuctor_then_throws_exception(self):
     with pytest.raises(MoodAnalyserException) as exception:
         analyser_object=MoodAnalyser(None)
         analyser_object.analyse_mood()
     assert str(exception.value)=="None mood is invalid"
def mood_analyser_object_with_sad():
    analyser_object = MoodAnalyser("I am sad")
    return analyser_object
def mood_analyser_object():
    analyser_object = MoodAnalyser()
    return analyser_object
def mood_analyser_object_with_happy():
    analyser_object = MoodAnalyser("I am happy")
    return analyser_object
 def test_passes_for_happy_message_when_returns_happy(self):
     mood_object = MoodAnalyser()
     assert mood_object.analyse_mood("I am in happy mood!") == "Happy"
 def test_given_empty_mood_throws_exception(self):
     with pytest.raises(MoodAnalyserError) as mood_exception:
         mood_object = MoodAnalyser()
         mood_object.analyse_mood("")
     assert str(mood_exception.value) == "EMPTY_VALUE_EXCEPTION"
 def test_given_constructor_when_none_message_throws_exception(self):
     with pytest.raises(MoodAnalyserError) as mood_exception:
         mood_object = MoodAnalyser(None)
         mood_object.analyse_mood()
     assert str(mood_exception.value) == "NULL_VALUE_EXCEPTION"
 def test_passes_when_message_passed_through_constructor_for_sad_message(
         self):
     mood_object1 = MoodAnalyser("I am in sad mood")
     assert mood_object1.analyse_mood() == "Sad"
 def test_passes_when_message_passed_through_constructor_for_happy_message(
         self):
     mood_object1 = MoodAnalyser("I am in happy mood")
     assert mood_object1.analyse_mood() == "Happy"
 def test_passes_for_sad_message_when_returns_sad(self):
     mood_object = MoodAnalyser()
     assert mood_object.analyse_mood("I am in sad mood!") == "Sad"