コード例 #1
0
  def testThatValuesAreAvailableAsDictItemsOfSection(self):
    attrName = uniqStr()
    attrValue = uniqStr()
    config = self.loadConfigWithContent(r'''[section]
%s = %s''' % (attrName, attrValue))

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

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

        assert config.section[attrName] == attrValue
コード例 #4
0
  def testThatValuesAreAvailableAsPropertiesOfASection(self):
    attrName = uniqStr()
    attrValue = uniqStr()
    config = self.loadConfigWithContent(r'''[section]
%s = %s''' % (attrName, attrValue))

    assert getattr(config.section, attrName) == attrValue
コード例 #5
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
コード例 #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
コード例 #7
0
  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
コード例 #8
0
  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
コード例 #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
コード例 #10
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
コード例 #11
0
  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
コード例 #12
0
 def testThatCDataIsReturnedIfElementHasNoAttributesOrChildren(self):
   expected = uniqStr()
   self.config = self.loadConfigWithContent('<top>%s</top>' % expected)
   assert self.config.top == expected
コード例 #13
0
 def setup_method(self, method):
   super(WhenAccessingTopLevelElement, self).setup_method(method)
   self.elementName = uniqStr()
   self.config = self.loadConfigWithContent('<%s />' % self.elementName)
コード例 #14
0
 def testThatConfigDoesNotContainItemsThatAreNotTopLevelElement(self):
   assert uniqStr() not in self.config
コード例 #15
0
 def testThatConfigDoesNotHavePropertyForWrongTopLevelElement(self):
   assert not hasattr(self.config, uniqStr())
コード例 #16
0
 def testThatConfigContainsSections(self):
   expected = uniqStr()
   config = self.loadConfigWithContent('[%s]' % expected)
   assert expected in config
コード例 #17
0
  def setup_method(self, method):
    super(WhenAccessingLists, self).setup_method(method)

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

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

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

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

        self.data = uniqStr()
コード例 #33
0
 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))
コード例 #34
0
 def testThatSectionsAreAvailableAsDictItems(self):
   expected = uniqStr()
   config = self.loadConfigWithContent('[%s]' % expected)
   assert config[expected] is not None
コード例 #35
0
    def testThatSectionsContainOptions(self):
        attrName = uniqStr()
        config = self.loadConfigWithContent(r'''[section]
%s = %s''' % (attrName, uniqStr()))

        assert attrName in config.section
コード例 #36
0
 def testThatInvalidNameIsNotPropertyOfParent(self):
     assert not hasattr(self.config.top, uniqStr())