def test_add_obj(self):
     knowledge_base = kb.KnowledgeBase(kb.make_objects_dict())
     knowledge_base.aj_obj("my_new_obj", "my_new_desc")
     obj = knowledge_base.find_obj("my_new_obj")
     self.assertEqual(type(obj), kb.GenericMathObject)
     self.assertEqual(obj.get_name(), "my_new_obj")
     self.assertEqual(obj.get_description(), "my_new_desc")
    def test_add_evaluate_invalid_args(self):
        add_command = Add()
        base = kb.KnowledgeBase(kb.make_objects_dict())

        with self.assertRaises(Exception) as context:
            add_command.evaluate("", ["obj_name"], base)

        self.assertTrue('Invalid number of arguments : add NAME DESCRIPTION' in str(context.exception))
 def test_add_evaluate(self):
     add_command = Add()
     base = kb.KnowledgeBase(kb.make_objects_dict())
     cont, state, message = add_command.evaluate("", ["obj_name", "obj_desc"], base)
     self.assertEqual(cont, False)
     self.assertEqual(state, "")
     self.assertEqual(message, "Successfully added the object : obj_name / obj_desc")
     self.assertEqual(base.find_obj("obj_name").get_description(), "obj_desc")
    def test_add_evaluate_already_exist(self):
        add_command = Add()
        base = kb.KnowledgeBase(kb.make_objects_dict())
        cont, state, message = add_command.evaluate("", ["obj_name", "obj_desc"], base)
        self.assertEqual(cont, False)
        self.assertEqual(state, "")
        self.assertEqual(message, "Successfully added the object : obj_name / obj_desc")

        cont, state, message = add_command.evaluate("", ["obj_name", "obj_desc"], base)
        self.assertEqual(cont, False)
        self.assertEqual(state, "")
        self.assertEqual(message, "Object already in DB")
 def test_find_obj(self):
     knowledge_base = kb.KnowledgeBase(kb.make_objects_dict())
     prime = kb.GenericMathObject("Prime", "Prime  number")
     base_prime1 = knowledge_base.find_obj("Prime")
     self.assertEqual(prime.get_name(), base_prime1.get_name())
 def test_find_obj_not_found(self):
     knowledge_base = kb.KnowledgeBase(kb.make_objects_dict())
     base_prime2 = knowledge_base.find_obj("caca")
     print(base_prime2)
    def test_find_obj2(self):
        knowledge_base = kb.KnowledgeBase(kb.make_objects_dict())
        base_prime1 = knowledge_base.find_obj("Prime")
        base_prime2 = knowledge_base.find_obj("Prime")

        self.assertEqual(base_prime1, base_prime2)