def testThatValuesAreAvailableAsDictItemsOfSection(self):
    attrName = uniqStr()
    attrValue = uniqStr()
    config = self.loadConfigWithContent(r'''[section]
%s = %s''' % (attrName, attrValue))

    assert config.section[attrName] == attrValue
Exemple #2
0
    def testThatValuesAreAvailableAsPropertiesOfASection(self):
        attrName = uniqStr()
        attrValue = uniqStr()
        config = self.loadConfigWithContent(r'''[section]
%s = %s''' % (attrName, attrValue))

        assert getattr(config.section, attrName) == attrValue
Exemple #3
0
    def testThatValuesAreAvailableAsDictItemsOfSection(self):
        attrName = uniqStr()
        attrValue = uniqStr()
        config = self.loadConfigWithContent(r'''[section]
%s = %s''' % (attrName, attrValue))

        assert config.section[attrName] == attrValue
  def testThatValuesAreAvailableAsPropertiesOfASection(self):
    attrName = uniqStr()
    attrValue = uniqStr()
    config = self.loadConfigWithContent(r'''[section]
%s = %s''' % (attrName, attrValue))

    assert getattr(config.section, attrName) == attrValue
  def testThatGettingChildrenOfConfigReturnsDictOfSections(self):
    expected = {}
    data = '[section]\n'
    for i in range(5):
      optionName = uniqStr()
      optionValue = uniqStr()
      data += '%s = %s\n' % (optionName, optionValue)
      expected[optionName.lower()] = optionValue

    config = self.loadConfigWithContent(data)

    actual = config.section.getChildren()
    assert actual == expected
Exemple #6
0
    def testThatGettingChildrenOfConfigReturnsDictOfSections(self):
        expected = {}
        data = '[section]\n'
        for i in range(5):
            optionName = uniqStr()
            optionValue = uniqStr()
            data += '%s = %s\n' % (optionName, optionValue)
            expected[optionName.lower()] = optionValue

        config = self.loadConfigWithContent(data)

        actual = config.section.getChildren()
        assert actual == expected
  def testThatGettingChildrenReturnsAttributeNames(self):
    content = '<top '
    attributes = []
    for i in range(5):
      attributeName = uniqStr()
      content += '%s="%s" ' % (attributeName, uniqStr())
      attributes.append(attributeName)
    content += ' />'

    self.config = self.loadConfigWithContent(content)
    children = self.config.top.getChildren()

    assert len(children) == len(attributes)
    for attributeName in attributes:
      assert attributeName in children
  def testThatGettingChildrenOfConfigReturnsTopLevelElement(self):
    content = uniqStr()
    self.config = self.loadConfigWithContent('<top>%s</top>' % content)

    children = self.config.getChildren()
    assert len(children) == 1
    assert children[0] == content
Exemple #9
0
    def testThatGettingChildrenOfConfigReturnsDictOfSections(self):
        expected = []
        data = ''
        for i in range(5):
            sectionName = uniqStr()
            data += '[%s]\n' % sectionName
            expected.append(sectionName)

        config = self.loadConfigWithContent(data)

        actual = config.getChildren().keys()
        for i in range(5):
            assert expected[i] in actual
  def testThatGettingChildrenOfConfigReturnsDictOfSections(self):
    expected = []
    data = ''
    for i in range(5):
      sectionName = uniqStr()
      data += '[%s]\n' % sectionName
      expected.append(sectionName)

    config = self.loadConfigWithContent(data)

    actual = config.getChildren().keys()
    for i in range(5):
      assert expected[i] in actual
  def testThatGettingChildrenReturnsChildElementNames(self):
    content = '<top>'
    elements = []
    for i in range(5):
      elementName = uniqStr()
      content += '<%s />' % elementName
      elements.append(elementName)
    content += '</top>'

    self.config = self.loadConfigWithContent(content)
    children = self.config.top.getChildren()

    assert len(children) == len(elements)
    for elementName in elements:
      assert elementName in children
 def testThatCDataIsReturnedIfElementHasNoAttributesOrChildren(self):
   expected = uniqStr()
   self.config = self.loadConfigWithContent('<top>%s</top>' % expected)
   assert self.config.top == expected
 def setup_method(self, method):
   super(WhenAccessingTopLevelElement, self).setup_method(method)
   self.elementName = uniqStr()
   self.config = self.loadConfigWithContent('<%s />' % self.elementName)
 def testThatConfigDoesNotContainItemsThatAreNotTopLevelElement(self):
   assert uniqStr() not in self.config
 def testThatConfigDoesNotHavePropertyForWrongTopLevelElement(self):
   assert not hasattr(self.config, uniqStr())
 def testThatConfigContainsSections(self):
   expected = uniqStr()
   config = self.loadConfigWithContent('[%s]' % expected)
   assert expected in config
  def setup_method(self, method):
    super(WhenAccessingLists, self).setup_method(method)

    self.firstData = uniqStr()
    self.secondData = uniqStr()
Exemple #18
0
    def testThatSectionsDoNotHavePropertiesForValuesNotInConfig(self):
        config = self.loadConfigWithContent(r'''[section]
name = value''')
        assert not hasattr(config.section, uniqStr())
Exemple #19
0
 def testThatSectionsAreAvailableAsDictItems(self):
     expected = uniqStr()
     config = self.loadConfigWithContent('[%s]' % expected)
     assert config[expected] is not None
  def setup_method(self, method):
    super(WhenAccessingCData, self).setup_method(method)

    self.data = uniqStr()
Exemple #21
0
 def testThatConfigContainsSections(self):
     expected = uniqStr()
     config = self.loadConfigWithContent('[%s]' % expected)
     assert expected in config
 def setup_method(self, method):
     super(WhenAccessingChildElements, self).setup_method(method)
     self.elementName = uniqStr()
     self.config = self.loadConfigWithContent('<top><%s /></top>' %
                                              self.elementName)
 def testThatInvalidNameIsNotPropertyOfParent(self):
     assert not hasattr(self.config.top, uniqStr())
  def testThatSectionsContainOptions(self):
    attrName = uniqStr()
    config = self.loadConfigWithContent(r'''[section]
%s = %s''' % (attrName, uniqStr()))

    assert attrName in config.section
Exemple #25
0
 def testThatSectionsArePropertiesOfConfig(self):
     expected = uniqStr()
     config = self.loadConfigWithContent('[%s]' % expected)
     assert hasattr(config, expected)
 def testThatConfigDoesNotHavePropertiesForSectionsNotInConfig(self):
   config = self.loadConfigWithContent('[section]')
   assert not hasattr(config, uniqStr())
Exemple #27
0
 def testThatConfigDoesNotHavePropertiesForSectionsNotInConfig(self):
     config = self.loadConfigWithContent('[section]')
     assert not hasattr(config, uniqStr())
  def testThatSectionsDoNotHavePropertiesForValuesNotInConfig(self):
    config = self.loadConfigWithContent(r'''[section]
name = value''')
    assert not hasattr(config.section, uniqStr())
    def setup_method(self, method):
        super(WhenAccessingLists, self).setup_method(method)

        self.firstData = uniqStr()
        self.secondData = uniqStr()
 def testThatSectionsArePropertiesOfConfig(self):
   expected = uniqStr()
   config = self.loadConfigWithContent('[%s]' % expected)
   assert hasattr(config, expected)
 def setup_method(self, method):
     super(WhenAccessingChildElements, self).setup_method(method)
     self.elementName = uniqStr()
     self.config = self.loadConfigWithContent("<top><%s /></top>" % self.elementName)
Exemple #32
0
    def setup_method(self, method):
        super(WhenAccessingCData, self).setup_method(method)

        self.data = uniqStr()
 def setup_method(self, method):
     super(WhenAccessingAttributes, self).setup_method(method)
     self.attributeName = uniqStr()
     self.attributeValue = uniqStr()
     self.config = self.loadConfigWithContent(
         '<top %s = "%s"/>' % (self.attributeName, self.attributeValue))
 def testThatSectionsAreAvailableAsDictItems(self):
   expected = uniqStr()
   config = self.loadConfigWithContent('[%s]' % expected)
   assert config[expected] is not None
Exemple #35
0
    def testThatSectionsContainOptions(self):
        attrName = uniqStr()
        config = self.loadConfigWithContent(r'''[section]
%s = %s''' % (attrName, uniqStr()))

        assert attrName in config.section
 def testThatInvalidNameIsNotPropertyOfParent(self):
     assert not hasattr(self.config.top, uniqStr())