Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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