Example #1
0
    def test_from_lxml_definitions(self):
        text = '''<MYSERVER>
  <DEFINE name="a" />
  <DEFINE>
    <DEFINE name="b" />
    <DEFINE name="c" />
  </DEFINE>
</MYSERVER>'''
        config = MyServerConfig.from_lxml_element(etree.XML(text))
        right = MyServerConfig([DefinitionElement('a'), DefinitionTree(
                    definitions = [DefinitionElement('b'),
                                   DefinitionElement('c')])])
        self.assertEqual(config, right)
Example #2
0
 def get_server_configuration(self):
     '''Get server settings.'''
     return MyServerConfig.from_string(self.get_file('&&&server'))
Example #3
0
 def test_from_lxml(self):
     text = '<MYSERVER />'
     config = MyServerConfig.from_lxml_element(etree.XML(text))
     right = MyServerConfig()
     self.assertEqual(config, right)
Example #4
0
 def test_from_string(self):
     text = '<MYSERVER />'
     config = MyServerConfig.from_string(text)
     right = MyServerConfig()
     self.assertEqual(config, right)
Example #5
0
 def test_definitions(self):
     config = MyServerConfig()
     self.assertEqual([], config.get_definitions())
     counter = 0
     for definition in self.definitions:
         config.add_definition(definition)
         counter += 1
         self.assertEqual(self.definitions[:counter],
                          config.get_definitions())
     for counter in xrange(len(self.definitions)):
         self.assertEqual(self.definitions[counter],
                          config.get_definition(counter))
     config.add_definition(DefinitionElement('test'), 1)
     self.assertEqual(DefinitionElement('test'), config.get_definition(1))
     config.remove_definition(1)
     self.assertEqual(self.definitions, config.get_definitions())
     for counter in xrange(len(self.definitions)):
         config.remove_definition(0)
         self.assertEqual(self.definitions[counter + 1:],
                          config.get_definitions())
Example #6
0
 def test_to_string_definitions(self):
     config = MyServerConfig([DefinitionElement('a'), DefinitionTree(
                 definitions = [DefinitionElement('b'),
                                DefinitionElement('c')])])
     copy = MyServerConfig.from_lxml_element(config.to_lxml_element())
     self.assertEqual(config, copy)
Example #7
0
 def test_to_string(self):
     config = MyServerConfig()
     copy = MyServerConfig.from_lxml_element(config.to_lxml_element())
     self.assertEqual(config, copy)
Example #8
0
 def test_to_string(self):
     config = MyServerConfig()
     copy = MyServerConfig.from_string(str(config))
     self.assertEqual(config, copy)