Beispiel #1
0
 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
Beispiel #2
0
    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
Beispiel #3
0
 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
Beispiel #4
0
 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
Beispiel #5
0
    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
Beispiel #6
0
 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
Beispiel #7
0
 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
Beispiel #8
0
    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