def __init__(self, fname, lname, email, password, phNo, age, gender, address, city, datetime, role, verification_code, employeeID, cnic, hiring_date, status): User.__init__(self, fname, lname, email, password, phNo, age, gender, address, city, datetime, role, verification_code) self.employeeID = employeeID self.cnic = cnic self.hiring_date = hiring_date self.status = status
def test_create(self): """Test creation of a new instance of User. """ new = User() trex = r"\w+[-]\w+[-]\w+[-]\w+[-]\w+" self.assertTrue(type(new.id) == str) self.assertTrue(search(trex, new.id)) self.assertTrue(type(new.created_at) == datetime.datetime) self.assertTrue(type(new.updated_at) == datetime.datetime) with self.assertRaises(TypeError) as error: User.__init__() msg = "__init__() missing 1 required positional argument: 'self'" self.assertEqual(msg, str(error.exception))
def test_no_arg_init(self): """ Test insantiation with no args """ self.resetStorage() with self.assertRaises(TypeError): User.__init__()
def __init__(self, fname,lname,email,password,phNo,age,gender,address,city,datetime,role,verification_code,username,customer_id=None): User.__init__(self, fname,lname,email,password,phNo,age,gender,address,city,datetime,role,verification_code) self.username = username self.customer_id = uuid.uuid4().hex if customer_id is None else customer_id