def testEscapeCorrectly(self): fields = [ ( 'vuur.aap' , 'normal' ), ( 'vuurboom.aap' , 'normal' ), ] x = '<root>%s</root>' % generateXml(fields) self.assertEqual("""<root><field name="vuur.aap">normal</field><field name="vuurboom.aap">normal</field></root>""", x)
def testEscapeCorrectly(self): fields = [ ( 'vuur.aap' , 'normal' ), ( 'vuurboom.aap' , 'normal' ), ] x = '<root>%s</root>' % generateXml(fields) self.assertEquals("""<root><field name="vuur.aap">normal</field><field name="vuurboom.aap">normal</field></root>""", x)
def testEscapeTagNamesAndValues(self): self.assertEquals("""<field name="k/\\.sub">value</field>""", generateXml([('k/\\.sub', 'value')])) self.assertEquals('<field name="key"></tag></field>', generateXml([('key', '</tag>')]))
def testGenerateXml(self): self.assertEquals( '<field name="a.b.c.d">DDD</field><field name="a.b.c.e">EEE</field><field name="a.b.c">CCC</field><field name="a.b.f">FFF</field><field name="a.b.c.d">DDD</field>', generateXml([('a.b.c.d', 'DDD'), ('a.b.c.e', 'EEE'), ('a.b.c', 'CCC'), ('a.b.f', 'FFF'), ('a.b.c.d', 'DDD')]))
def testGenerateOtherParentKeyXml(self): self.assertEquals( '<field name="a.b">value</field><field name="c.d">value2</field>', generateXml([('a.b', 'value'), ('c.d', 'value2')]))
def testGenerateOneSubKeyXml(self): self.assertEquals('<field name="key.sub">value</field>', generateXml([('key.sub', 'value')]))
def testEscapeTagNamesAndValues(self): self.assertEquals("""<field name="k/\\.sub">value</field>""", generateXml([('k/\\.sub','value')])) self.assertEquals('<field name="key"></tag></field>', generateXml([('key','</tag>')]))
def testGenerateXml(self): self.assertEquals('<field name="a.b.c.d">DDD</field><field name="a.b.c.e">EEE</field><field name="a.b.c">CCC</field><field name="a.b.f">FFF</field><field name="a.b.c.d">DDD</field>', generateXml([('a.b.c.d','DDD'), ('a.b.c.e','EEE'), ('a.b.c', 'CCC'),('a.b.f', 'FFF'), ('a.b.c.d', 'DDD')]))
def testGenerateOtherParentKeyXml(self): self.assertEquals('<field name="a.b">value</field><field name="c.d">value2</field>', generateXml([('a.b','value'), ('c.d','value2')]))
def testGenerateOneSubKeyXml(self): self.assertEquals('<field name="key.sub">value</field>', generateXml([('key.sub','value')]))
def testGenerateOneKeyXml(self): self.assertEqual('<field name="key">value</field>', generateXml([('key','value')]))