def testGetOptionWithValidationBoolOnNonBool (self): # Setup with file known to exist, with section and key known to exist. tstCV = ConfigValues (self.EXISTING_FILENAME) tstCV.InitConfig() resultBool = tstCV.GetOptionWithValidation (self.EXISTING_SECTIONNAME, self.EXISTING_KEYNAME_STRING, False) assert resultBool == False # resultBool should contain the DEFAULT value, in this case, False.
def testGetOptionWithValidationBoolOnBool (self): # Setup with file known to exist, with section and key known to exist. tstCV = ConfigValues (self.EXISTING_FILENAME) tstCV.InitConfig() resultBool = tstCV.GetOptionWithValidation (self.EXISTING_SECTIONNAME, self.EXISTING_KEYNAME_BOOL, True) assert resultBool == True
def testGetOptionWithValidationStringOnExactFail (self): # Setup with file known to exist, with section and key known to exist. tstCV = ConfigValues (self.EXISTING_FILENAME) tstCV.InitConfig() resultStr = tstCV.GetOptionWithValidation (self.EXISTING_SECTIONNAME, self.EXISTING_KEYNAME_STRING, "StringDefaultValue", list([self.EXISTING_KEY_STRINGVALUE + "junk"])) assert resultStr == "StringDefaultValue"
def testGetOptionWithValidationStringOnContainsFail (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.GetOptionWithValidation (self.EXISTING_SECTIONNAME, self.EXISTING_KEYNAME_STRING, "StringDefaultValue", testStringValues) assert resultStr == "StringDefaultValue"
def testGetOptionWithValidationStringOnContainsPass (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 CONTAINS the string to be tested. testStringValues = list(["sixOfOne", self.EXISTING_KEY_STRINGVALUE, "halfDozenOfTheOther"]) resultStr = tstCV.GetOptionWithValidation (self.EXISTING_SECTIONNAME, self.EXISTING_KEYNAME_STRING, self.DEFAULT_VALUE_STRING, testStringValues) assert resultStr == self.EXISTING_KEY_STRINGVALUE