def test_simple_file_validator_invalid_extension(self): validator = simple_file_validator.SimpleFileValidator('assessment') results = validator.execute(self.data_dir, 'invalid_ext.xls', 1) self.assertEqual(results[0][0], ErrorCode.SRC_FILE_TYPE_NOT_SUPPORTED) validator = simple_file_validator.SimpleFileValidator( 'studentregistration') results = validator.execute(self.data_dir, 'invalid_ext.xls', 1) self.assertEqual(results[0][0], ErrorCode.SRC_FILE_TYPE_NOT_SUPPORTED)
def test_simple_file_validator_fails_for_missing_csv(self): validator = simple_file_validator.SimpleFileValidator('assessment') results = validator.execute(self.data_dir, 'nonexistent.csv', 1) self.assertEqual(results[0][0], ErrorCode.SRC_FILE_NOT_ACCESSIBLE_SFV, "Wrong error code") validator = simple_file_validator.SimpleFileValidator( 'studentregistration') results = validator.execute(self.data_dir, 'nonexistent.csv', 1) self.assertEqual(results[0][0], ErrorCode.SRC_FILE_NOT_ACCESSIBLE_SFV, "Wrong error code")
def test_simple_file_validator_passes_for_valid_student_reg_csv(self): validator = simple_file_validator.SimpleFileValidator( 'studentregistration') results = validator.execute( self.data_dir, 'student_registration_data/test_sample_student_reg.csv', 1) self.assertEqual(len(results), 0)
def test_extention_errorcode(self): #test#8 --> different file formate other than csv & json expected_error_code = simple_file_validator.SimpleFileValidator( 'assessment').execute(self.data_dir, "REALDATA_3010.xlsx", 123) self.assertEqual( expected_error_code[0][0], ErrorCode.SRC_FILE_TYPE_NOT_SUPPORTED, "Validation Code for different file formate is incorrect")
def test_invalid_content_student_registration_json(self): validator = simple_file_validator.SimpleFileValidator( 'studentregistration') results = validator.execute( self.data_dir, 'student_registration_data/test_invalid_student_reg.json', 1) error_code_expected = ErrorCode.SRC_JSON_INVALID_FORMAT expected_field = 'academic_year' self.assertEqual(len(results), 1) self.assertEqual(results[0][0], error_code_expected) self.assertEqual(results[0][4], expected_field)
def test_simple_file_validator_wrong_delimiter(self): validator = simple_file_validator.SimpleFileValidator('assessment') results = validator.execute(self.data_dir, 'REALDATA_3005.csv', 1) self.assertEqual(results[1][0], ErrorCode.SRC_FILE_WRONG_DELIMITER)
def test_simple_file_validator_passes_for_valid_assmt_csv(self): validator = simple_file_validator.SimpleFileValidator('assessment') results = validator.execute( self.base_data_dir, 'test_data_latest/' 'REALDATA_ASMT_ID_76a9ab517e76402793d3f2339391f5.csv', 1) self.assertEqual(len(results), 0)