def test_validator_age_invalid_string(self): val = Validator() test_data = "Blah" expected_result = False actual_result = val.Validate_Age(test_data)[0] self.assertEqual(actual_result, expected_result, "actaul_result should equal" + str(expected_result))
def test_validator_age_valid_1(self): val = Validator() test_data = 23 expected_result = True actual_result = val.Validate_Age(test_data)[0] self.assertEqual(actual_result, expected_result, "actaul_result should equal" + str(expected_result))
def read_file_txt(self, all_my_employees): with open("test_data_txt.txt", "r") as file: data = file.readlines() clean = Cleaner() val = Validator() for line in data: valid = True emp = line.split(",") empid = clean.clean_empid(emp[0]) if val.val_empid(all_my_employees, empid)[0] == False: valid = False print("empid") gender = clean.clean_gender(emp[1]) if val.val_gender(gender)[0] == False: valid = False print("gender") age = clean.Clean_Age(emp[2]) if val.Validate_Age(age[0])[0] == False: valid = False print("age") sales = emp[3] bmi = clean.clean_bmi(emp[4]) if val.val_bmi(bmi)[0] == False: valid = False print("bmi") salary = emp[5] # there is an issue with the validation of the test data's birthdays birthday = clean.Clean_Birthday(emp[6]) # if val.Validate_Birthday(birthday, age[0]+ 1 )[0]: # pass # else: # valid = False # print("birthday") if valid != False: employee = Employee(empid, gender, age[0], sales, bmi, salary, birthday[0]) all_my_employees[empid] = employee else: print("Failed to add employee") return all_my_employees