def test_property(self): with self.assertRaises(ValueError): obj = Person() obj.name = 3 with self.assertRaises(ValueError): obj = Person() obj.age = "a" obj = Person() obj.name = "string" obj.age = 1 self.assertEqual(obj.name, "string") self.assertEqual(obj.age, 1)
def test_different_object(self): obj1 = Person() obj1.name = "string" obj1.age = 1 self.assertEqual(obj1.name, "string") self.assertEqual(obj1.age, 1) obj2 = Person() obj2.name = "new" obj2.age = 2 self.assertEqual(obj2.name, "new") self.assertEqual(obj2.age, 2) self.assertEqual(obj1.name, "string") self.assertEqual(obj1.age, 1)
def test_put(self): p = Person("philip", "folk", 20) self.assertIsNone(p.uuid) p = storage.put(p) self.assertIsNotNone(p.uuid) p.name = "petter" new_p = storage.put(p) self.assertEqual(new_p.uuid, p.uuid)