예제 #1
0
 def test_print_args(self):
     """ Test __str__ with args """
     b1 = BaseModel(None, 1, ["A"])
     b1.name = "Holberton"
     b1.code = 123
     s = "[{:s}] ({:s}) {:s}\n"
     s = s.format(b1.__class__.__name__, b1.id, str(b1.__dict__))
     with patch('sys.stdout', new=io.StringIO()) as p:
         print(b1)
         st = p.getvalue()
         self.assertEqual(st, s)
예제 #2
0
    def test_to_dict(self):
        """ Checks for correct dictionary conversion """
        b1 = BaseModel()
        b1.name = "Holberton"
        b1.code = 123
        d = {}
        d["id"] = b1.id
        d["created_at"] = b1.created_at.isoformat()
        d["updated_at"] = b1.updated_at.isoformat()
        d["name"] = b1.name
        d["code"] = b1.code

        dic = b1.to_dict()

        self.assertEqual(d["id"], dic["id"])
        self.assertEqual(d["created_at"], dic["created_at"])
        self.assertEqual(d["updated_at"], dic["updated_at"])
        self.assertEqual(d["name"], dic["name"])
        self.assertEqual(d["code"], dic["code"])