def testValidateSalesData_allSuccesses(self): df = getDfFromFile(self.INVALID_EXCEL_ALL_SUCCESSES) featuresList, featureNameMapping = getFeaturesFromDf(df) expectedErrorMessages = [ Messages.INVALID_SUCCESS_VALUES] # Test validSalesData, errorMessages = validateSalesData(featuresList, featureNameMapping, df) # Validate self.assertEqual(validSalesData, False) self.assertEqual(errorMessages, expectedErrorMessages)
def testValidateSalesData_allProblems(self): df = getDfFromFile(self.INVALID_CSV_ALL_PROBLEMS) featuresList, featureNameMapping = getFeaturesFromDf(df) expectedErrorMessages = [ Messages.MISSING_CLIENT_ID_COLUMN, Messages.INVALID_SUCCESS_VALUES, Messages.createEmptyCellsInColumnsMessage(['Referral', 'Opportunity Business Area'])] # Test validSalesData, errorMessages = validateSalesData(featuresList, featureNameMapping, df) # Validate self.assertEqual(validSalesData, False) self.assertEqual(errorMessages, expectedErrorMessages)
def testValidateSalesData_missingRequiredCols(self): df = getDfFromFile(self.INVALID_CSV_MISSING_REQUIRED_COLS) featuresList, featureNameMapping = getFeaturesFromDf(df) expectedErrorMessages = [ Messages.MISSING_CLIENT_ID_COLUMN, Messages.MISSING_SALESPERSON_ID_COLUMN, Messages.MISSING_SUCCESS_COLUMN] # Test validSalesData, errorMessages = validateSalesData(featuresList, featureNameMapping, df) # Validate self.assertEqual(validSalesData, False) self.assertEqual(errorMessages, expectedErrorMessages)
def testValidatePreprocessingInput_invalidNumericaText(self): df = getDfFromFile(self.INVALID_EXCEL_INVALID_NUMERICAL_TEXT_FEATURE) formField1 = PreprocessingFormField('NumericalNumber', FeatureTypeChoice.NUMERICAL.value, DataTypeChoice.NUMBER.value) formField2 = PreprocessingFormField('ValidNumericalText', FeatureTypeChoice.NUMERICAL.value, DataTypeChoice.TEXT.value) formField3 = PreprocessingFormField('InvalidNumericalText', FeatureTypeChoice.NUMERICAL.value, DataTypeChoice.TEXT.value) formFields = [formField1, formField2, formField3] expectedErrorMessages = [ Messages.createInvalidNumericalFeatureTypeMessage( formField3.featureName, formField3.featureType, formField3.dataType)] # Test validPreprocessingInput, errorMessages = validatePreprocessingInput(formFields, df) # Validate self.assertEqual(validPreprocessingInput, False)
def testGetFeaturesFromDf(self): df = getDfFromFile(self.INVALID_CSV_ALL_PROBLEMS) expectedFeatureNameMapping = { 'client ids': 'Client IDs', 'referral': 'Referral', 'sales process': 'Sales Process', 'opportunity business area': 'Opportunity Business Area', 'salesperson id': 'Salesperson ID', 'success': 'Success', } expectedInputFeatures = ['client ids', 'referral', 'sales process', 'opportunity business area', 'salesperson id', 'success'] # Test featuresList, featureNameMapping = getFeaturesFromDf(df) # Validate self.assertEqual(featuresList, expectedInputFeatures) self.assertEqual(featureNameMapping, expectedFeatureNameMapping)
def testValidatePreprocessingInput_invalidBooleanNumber(self): df = getDfFromFile(self.INVALID_EXCEL_INVALID_BOOLEAN_NUMBER_FEATURE) formField1 = PreprocessingFormField('ValidBooleanNumber', FeatureTypeChoice.BOOLEAN.value, DataTypeChoice.NUMBER.value) formField2 = PreprocessingFormField('ValidBooleanNumber2', FeatureTypeChoice.BOOLEAN.value, DataTypeChoice.NUMBER.value) formField3 = PreprocessingFormField('ValidBooleanNumber3', FeatureTypeChoice.BOOLEAN.value, DataTypeChoice.NUMBER.value) formField4 = PreprocessingFormField('InvalidBooleanNumber', FeatureTypeChoice.BOOLEAN.value, DataTypeChoice.NUMBER.value) formFields = [formField1, formField2, formField3, formField4] expectedErrorMessages = [ Messages.createInvalidBooleanFeatureTypeMessage( formField4.featureName, formField4.featureType, formField4.dataType), ] # Test validPreprocessingInput, errorMessages = validatePreprocessingInput(formFields, df) # Validate self.assertEqual(validPreprocessingInput, False) self.assertEqual(errorMessages, expectedErrorMessages)