def test_to_dic(self):
     '''Test the correct output of the 'to_dic' method'''
     test3 = BaseModel()
     dic = test3.to_dict()
     self.assertEqual(len(dic), 4)
     test3.name = 'John'
     dic = test3.to_dict()
     self.assertEqual(len(dic), 5)
     test3.last_name = 'Wick'
     dic = test3.to_dict()
     self.assertEqual(len(dic), 6)
     for i in dic.values():
         self.assertEqual(type(i), str)
Example #2
0
    def testUpdateExtraData(self):
        """Tests the update command with extra arguments"""
        b1 = BaseModel()
        b1.first_name = "Ben"
        b1.last_name = "Keener"

        with unittest.mock.patch("sys.stdout", new=StringIO()) as f:
            HBNBCommand().onecmd("update BaseModel {} first_name \"Drew\"\
                                 last_name \"foo\"".format(b1.id))
            self.assertEqual(f.getvalue().rstrip(), "")

        self.assertEqual(b1.first_name, "Drew")
        self.assertEqual(b1.last_name, "Keener")