def test_given_method_name_when_correct_returns_happy(self):
     mood_factory = MoodAnalyserFactory()
     mood_object = mood_factory.return_mood_analyser_object(
         "mood_analyser", "MoodAnalyser", "I am in happy mood!")
     mood = mood_factory.invoke_methods(mood_object, "analyse_mood",
                                        "I am in happy mood")
     assert mood is "Happy"
 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_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_method_name_when_incorrect_returns_throws_exception(self):
     mood_factory = MoodAnalyserFactory()
     mood_object = mood_factory.return_mood_analyser_object(
         "mood_analyser", "MoodAnalyser", "I am in happy mood!")
     with pytest.raises(MoodAnalyserError) as e:
         mood = mood_factory.invoke_methods(mood_object, "InvalidMethiod",
                                            "I am in happy mood")
         assert mood is "Happy"
     assert str(e.value) == "INVALID_METHOD_EXCEPTION"
 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"
def test_analysemood_givenclassname_whenimproper_shouldthrowexception():
    moodAnalyserFactory = MoodAnalyserFactory(
        mood_analyser="Iam in Happy mood")
    try:
        mood1 = moodAnalyserFactory
        mood2 = moodAnalyserFactory.mood_analyser
    except MoodAnalyserException as e:
        assert e.type == MoodAnalyserException.NoSuchClassError
def test_analysemood_whengiventwoobjects_ifequals_shouldretunequal():
    moodAnalyserFactory = MoodAnalyserFactory(
        mood_analyser="Iam in Happy mood")
    mood1 = moodAnalyserFactory.mood_analyser
    mood2 = moodAnalyserFactory.mood_analyser
    assert mood1 == mood2
Esempio n. 10
0
 def test_pass_when_given_wrong_field_should_throw_field_not_found_exception(self):
     with pytest.raises(MoodAnalyserException) as exception:
         assert MoodAnalyserFactory.invoke_method(MoodAnalyserFactory.set_field_dynamically(MoodAnalyserFactory.create_mood_analyser_object
                         ("mood_analyser","MoodAnalyser","I am sad"),"message1","I am happy"),"analyse_mood")
     assert str(exception.value)=="Field not found error"
Esempio n. 11
0
 def test_pass_when_given_field_when_proper_should_return_happy(self):
     assert MoodAnalyserFactory.invoke_method(MoodAnalyserFactory.set_field_dynamically(MoodAnalyserFactory.create_mood_analyser_object
                         ("mood_analyser","MoodAnalyser","I am sad"),"message","I am happy"),"analyse_mood")=="happy"
Esempio n. 12
0
 def test_pass_when_given_wrong_method_should_throw_method_not_found_exception(self):
     with pytest.raises(MoodAnalyserException) as exception:
         MoodAnalyserFactory.invoke_method(MoodAnalyserFactory.create_mood_analyser_object
                         ("mood_analyser","MoodAnalyser"),"analyse_mood1")
     assert str(exception.value)=="Method not found error"
Esempio n. 13
0
 def test_pass_when_given_method_should_return_happy(self):
     assert MoodAnalyserFactory.invoke_method(MoodAnalyserFactory.create_mood_analyser_object
                         ("mood_analyser","MoodAnalyser","I am happy"),"analyse_mood")=="happy"
Esempio n. 14
0
 def test_pass_when_given_filepath_should_throw_module_not_found_exception(self, mood_analyser_object):
     with pytest.raises(MoodAnalyserException) as exception:
         mood_analyser_object.equals(MoodAnalyserFactory.create_mood_analyser_object
                                       ("mood_analyser1","MoodAnalyser"))
     assert str(exception.value)=="Module not found error"
Esempio n. 15
0
 def test_pass_when_given_mood_analyse_class_with_message_should_return_object(self, mood_analyser_object_with_happy):
     assert mood_analyser_object_with_happy.equals(MoodAnalyserFactory.create_mood_analyser_object
                                       ("mood_analyser","MoodAnalyser","I am happy"))==True
Esempio n. 16
0
 def test_pass_when_given_mood_analyse_class_should_return_object(self,mood_analyser_object):
     assert mood_analyser_object.equals(MoodAnalyserFactory.create_mood_analyser_object
                                       ("mood_analyser","MoodAnalyser"))==True