def testIsBooleanOnNonBool (self): # Setup with file known to exist, with section and key known to exist. tstCV = ConfigValues (self.EXISTING_FILENAME) tstCV.InitConfig() resultBool = tstCV.GetOption (self.EXISTING_SECTIONNAME, self.EXISTING_KEYNAME_STRING) assert ConfigValues.isBoolean (resultBool) == False
def testNonExistentConfigValueFileNoDefault (self): # Setup with file known that is known to be non-existent. tstCV = ConfigValues(self.NON_EXISTENT_FILENAME) tstCV.InitConfig() # With no passed in default value resultNoDef = tstCV.GetOption (self.NON_EXISTENT_SECTIONNAME, self.NON_EXISTENT_KEYNAME) assert resultNoDef == self.NO_DEFAULT_VALUE
def testIsConstrainedNumberOnNegativeNumber (self): # Setup with file known to exist, with section and key known to exist. tstCV = ConfigValues (self.EXISTING_FILENAME) tstCV.InitConfig() resultIntNeg = tstCV.GetOption (self.EXISTING_SECTIONNAME, self.EXISTING_KEYNAME_INTNEG) assert ConfigValues.isConstrainedNumber (resultIntNeg, int) == False
def testIsConstrainedNumberOnFloat (self): # Setup with file known to exist, with section and key known to exist. tstCV = ConfigValues (self.EXISTING_FILENAME) tstCV.InitConfig() resultFloat = tstCV.GetOption (self.EXISTING_SECTIONNAME, self.EXISTING_KEYNAME_FLOAT) assert ConfigValues.isConstrainedNumber (resultFloat, float) == True
def testNonExistentKeyNoDefault (self): # Setup with file known to exist, with section known to exist. tstCV = ConfigValues(self.EXISTING_FILENAME) tstCV.InitConfig() # With no passed in default value resultNoDef = tstCV.GetOption (self.EXISTING_SECTIONNAME, self.NON_EXISTENT_KEYNAME) assert resultNoDef == self.NO_DEFAULT_VALUE
def testIsConstrainedStringExactPass (self): # Setup with file known to exist, with section and key known to exist. tstCV = ConfigValues (self.EXISTING_FILENAME) tstCV.InitConfig() resultStr = tstCV.GetOption (self.EXISTING_SECTIONNAME, self.EXISTING_KEYNAME_STRING) assert ConfigValues.isConstrainedString (resultStr, self.EXISTING_KEY_STRINGVALUE) == True
def testExistingKeyFormat2NoDefault (self): # Setup with file known to exist, with section and key known to exist. # Key-value pair format 2: Key:Value tstCV = ConfigValues (self.EXISTING_FILENAME) tstCV.InitConfig() # With no passed in default value resultNoDef = tstCV.GetOption (self.EXISTING_SECTIONNAME, self.EXISTING_KEYNAME_FORMAT2) assert resultNoDef == self.EXISTING_KEY_VALUE2
def testIsConstrainedStringContainsFail (self): # Setup with file known to exist, with section and key known to exist. tstCV = ConfigValues (self.EXISTING_FILENAME) tstCV.InitConfig() # List of strings which does NOT contain the string to be tested. testStringValues = list(["sixOfOne", "halfDozenOfTheOther"]) resultStr = tstCV.GetOption (self.EXISTING_SECTIONNAME, self.EXISTING_KEYNAME_STRING) assert ConfigValues.isConstrainedString (resultStr, testStringValues) == False