Exemplo n.º 1
0
    def test_add_property_to_configuration(self):
        doc = self.create_default_doc()
        x.add_properties_to_configuration(doc, 'test', {
            '': 'empty1',
            None: 'empty2'
        })
        self.assertEqual(
            doc.toprettyxml(indent="  "), """<?xml version="1.0" ?>
<test>
  <configuration/>
</test>
""")

        test_conf = {'name1': 'value1', 'name2': 'value2'}
        x.add_properties_to_configuration(doc, 'test', test_conf)

        self.assertEqual(
            doc.toprettyxml(indent="  "), """<?xml version="1.0" ?>
<test>
  <configuration>
    <property>
      <name>name2</name>
      <value>value2</value>
    </property>
    <property>
      <name>name1</name>
      <value>value1</value>
    </property>
  </configuration>
</test>
""")
        x.add_property_to_configuration(doc, 'name3', 'value3')
        self.assertEqual(
            doc.toprettyxml(indent="  "), """<?xml version="1.0" ?>
<test>
  <configuration>
    <property>
      <name>name2</name>
      <value>value2</value>
    </property>
    <property>
      <name>name1</name>
      <value>value1</value>
    </property>
    <property>
      <name>name3</name>
      <value>value3</value>
    </property>
  </configuration>
</test>
""")
Exemplo n.º 2
0
    def test_add_property_to_configuration(self):
        doc = self.create_default_doc()
        x.add_properties_to_configuration(doc, 'test', {'': 'empty1',
                                                        None: 'empty2'})
        self.assertEqual(doc.toprettyxml(indent="  "),
                         """<?xml version="1.0" ?>
<test>
  <configuration/>
</test>
""")

        test_conf = {'name1': 'value1', 'name2': 'value2'}
        x.add_properties_to_configuration(doc, 'test', test_conf)

        self.assertEqual(doc.toprettyxml(indent="  "),
                         """<?xml version="1.0" ?>
<test>
  <configuration>
    <property>
      <name>name2</name>
      <value>value2</value>
    </property>
    <property>
      <name>name1</name>
      <value>value1</value>
    </property>
  </configuration>
</test>
""")
        x.add_property_to_configuration(doc, 'name3', 'value3')
        self.assertEqual(doc.toprettyxml(indent="  "),
                         """<?xml version="1.0" ?>
<test>
  <configuration>
    <property>
      <name>name2</name>
      <value>value2</value>
    </property>
    <property>
      <name>name1</name>
      <value>value1</value>
    </property>
    <property>
      <name>name3</name>
      <value>value3</value>
    </property>
  </configuration>
</test>
""")
Exemplo n.º 3
0
 def _add_configuration_elements(self, configuration):
     if configuration:
         x.add_properties_to_configuration(self.doc, self.tag_name,
                                           configuration)
Exemplo n.º 4
0
 def _add_configuration_elements(self, configuration):
     if configuration:
         x.add_properties_to_configuration(self.doc, self.tag_name,
                                           configuration)