Exemplo n.º 1
0
 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.
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
 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"
Exemplo n.º 4
0
    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"
Exemplo n.º 5
0
    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