def send_to_validate(dict_root, switch, dup_keys): valid_rows = 0 invalid_rows = 0 for k, v in dict_root.items(): valid = 0 length_of_values = len(v) # if k != '': result = Ve.is_valid(k) if result[1]: valid += 1 for kv in v.keys(): if kv == 'gender': result = Vg.is_valid(dict_root[k][kv]) if result[1]: dict_root[k][kv] = result[0] valid += 1 if kv == 'bmi': result = Vb.is_valid(dict_root[k][kv]) if result[1]: dict_root[k][kv] = result[0] valid += 1 if kv == 'birthday': i = Vd() result = i.is_valid(dict_root[k][kv]) if result[1]: dict_root[k][kv] = result[0] valid += 1 if kv == 'age': i = Va() result = i.is_valid(dict_root[k][kv]) if result[1]: dict_root[k][kv] = result[0] valid += 1 if kv == 'salary': i = Vs() result = i.is_valid(dict_root[k][kv]) if result[1]: dict_root[k][kv] = str(result[0]) valid += 1 if kv == 'sales': i = Vsa() result = i.is_valid(dict_root[k][kv]) if result[1]: dict_root[k][kv] = result[0] valid += 1 if valid == length_of_values: dict_root[k]['valid'] = '1' valid_rows += 1 else: invalid_rows += 1 if switch.upper() == 'D': print("{0} Rows Of Valid Data".format(valid_rows)) print("{0} Rows Of Invalid Data".format(invalid_rows)) print("{0} Duplicate ID Key(s) appended to log".format(dup_keys)) return dict_root
def test_gender_female_with_special_characters(self): i = va.is_valid(' $@#$ fe #$# ma @#@$ 454 le 3435') self.assertTrue(i == ('F', True), "the value of test should be F")
def test_gender_male_with_special_characters(self): i = va.is_valid(' 23123 #$@#$ ma $#@$ le 9876@# ') self.assertTrue(i == ('M', True), "the value of test should be M")
def test_gender_girl(self): i = va.is_valid('girl') self.assertTrue(i == ('F', True), "the value of test should be F")
def test_gender_female(self): i = va.is_valid('female') self.assertTrue(i == ('F', True), "the value of test should be F")
def test_gender_dude(self): i = va.is_valid('dude') self.assertTrue(i == ('M', True), "the value of test should be M")