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
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
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()
def testThatSectionsDoNotHavePropertiesForValuesNotInConfig(self): config = self.loadConfigWithContent(r'''[section] name = value''') assert not hasattr(config.section, uniqStr())
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()
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
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())
def setup_method(self, method): super(WhenAccessingChildElements, self).setup_method(method) self.elementName = uniqStr() self.config = self.loadConfigWithContent("<top><%s /></top>" % self.elementName)
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))