Skip to content

Commit

Permalink
Add test for using xml namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Monika Sulik committed Apr 22, 2014
1 parent 838cabd commit e055b9f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/xml_tests.py
Expand Up @@ -418,3 +418,23 @@ def transform_info(self, infos):
test = TestXMLModel.import_data(xmldata)
self.assertEquals(test[0].name, "Jojo")
self.assertEquals(len(test[0].info), 1)

def test_using_namespace(self):
class TestXMLModel(XMLModel):
root = XMLRootField(path="person")
first_name = XMLCharField(path="first:name",
namespaces={'first': "http://example.com/first"})
last_name = XMLCharField(path="last:name",
namespaces={'last': "http://example.com/last"})

xmldata = """<data xmlns:first="http://example.com/first"
xmlns:last="http://example.com/last">
<person>
<first:name>Jojo</first:name>
<last:name>Gigi</last:name>
</person>
</data>"""
test = TestXMLModel.import_data(xmldata)
jojo = test[0]
self.assertEquals(jojo.first_name, "Jojo")
self.assertEquals(jojo.last_name, "Gigi")

0 comments on commit e055b9f

Please sign in to comment.