Ejemplo n.º 1
0
 def test_dict(self):
     """ dic_to method from BaseModel """
     brba = City()
     brba.name = "Paradise"
     brba.appartment = 4
     dicti = brba.to_dict()
     self.assertTrue("name" in dicti)
     self.assertEqual(type(dicti["name"]), str)
     self.assertTrue("appartment" in dicti)
     self.assertEqual(type(dicti["appartment"]), int)
     self.assertTrue("created_at" in dicti)
     self.assertTrue("updated_at" in dicti)
     self.assertTrue("id" in dicti)
Ejemplo n.º 2
0
 def test_recreate_from_kwargs(self):
     """ recreate the dictionary from saved one """
     brba = City()
     brba.name = "Paradise"
     brba.appartment = 9
     dicti = brba.to_dict()
     new_dicti = City(**dicti)
     self.assertEqual(brba.name, new_dicti.name)
     self.assertEqual(brba.appartment, new_dicti.appartment)
     self.assertEqual(brba.id, new_dicti.id)
     self.assertEqual(brba.created_at, new_dicti.created_at)
     self.assertEqual(brba.updated_at, new_dicti.updated_at)
     self.assertEqual(type(new_dicti.id), str)
     self.assertFalse(new_dicti is dicti)