Exemplo n.º 1
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)
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
0
 def test_from_lxml(self):
     text = '<MYSERVER />'
     config = MyServerConfig.from_lxml_element(etree.XML(text))
     right = MyServerConfig()
     self.assertEqual(config, right)
Exemplo n.º 5
0
 def test_from_string(self):
     text = '<MYSERVER />'
     config = MyServerConfig.from_string(text)
     right = MyServerConfig()
     self.assertEqual(config, right)
Exemplo n.º 6
0
 def test_equality(self):
     self.assertEqual(MyServerConfig(self.definitions),
                      MyServerConfig(self.definitions))
     self.assertNotEqual(MyServerConfig(), MyServerConfig(self.definitions))
     self.assertNotEqual(MyServerConfig(), 'other type')
Exemplo n.º 7
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())
Exemplo n.º 8
0
 def test_creation(self):
     config = MyServerConfig()
     config = MyServerConfig(self.definitions)
Exemplo n.º 9
0
 def test_to_string(self):
     config = MyServerConfig()
     copy = MyServerConfig.from_lxml_element(config.to_lxml_element())
     self.assertEqual(config, copy)
Exemplo n.º 10
0
 def test_to_string(self):
     config = MyServerConfig()
     copy = MyServerConfig.from_lxml_element(config.to_lxml_element())
     self.assertEqual(config, copy)
Exemplo n.º 11
0
 def test_to_string(self):
     config = MyServerConfig()
     copy = MyServerConfig.from_string(str(config))
     self.assertEqual(config, copy)
Exemplo n.º 12
0
 def test_from_lxml(self):
     text = '<MYSERVER />'
     config = MyServerConfig.from_lxml_element(etree.XML(text))
     right = MyServerConfig()
     self.assertEqual(config, right)
Exemplo n.º 13
0
 def test_from_string(self):
     text = '<MYSERVER />'
     config = MyServerConfig.from_string(text)
     right = MyServerConfig()
     self.assertEqual(config, right)
Exemplo n.º 14
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())
Exemplo n.º 15
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)
Exemplo n.º 16
0
 def get_server_configuration(self):
     '''Get server settings.'''
     return MyServerConfig.from_string(self.get_file('&&&server'))
Exemplo n.º 17
0
 def get_server_configuration(self):
     '''Get server settings.'''
     return MyServerConfig.from_string(self.get_file('&&&server'))
Exemplo n.º 18
0
 def test_to_string(self):
     config = MyServerConfig()
     copy = MyServerConfig.from_string(str(config))
     self.assertEqual(config, copy)