Skip to content

Commit ac1ded8

Browse files
committed
Fixes #98: Add tests for xmlToJson method.
To improve the code coverage and to be sure that method does give expected json data, we should add tests for this method.
1 parent 96418bb commit ac1ded8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ def test_hello(self):
3434
result = self.loklak.hello()
3535
self.assertEqual(result['status'], u'ok')
3636

37+
def test_xmlToJson(self):
38+
"""Test xmlToJson method."""
39+
xmlData = "<note>\n<to>Coders</to>\n<from>FOSSASIA</from>\n<heading>FOSSASIA</heading> \
40+
\n<body>Let's code!!</body>\n</note>"
41+
expectedJSONData = '{"note": {"to": {"$": "Coders"}, "from": {"$": "FOSSASIA"}, "heading": {"$": "FOSSASIA"}, "body": {"$": "Let\'s code!!"}}}'
42+
result = self.loklak.xmlToJson(xmlData)
43+
self.assertEqual(result, expectedJSONData)
44+
result = self.loklak.xmlToJson()
45+
self.assertEqual(result, "[]")
46+
3747
def test_geocode(self):
3848
"""Test geological features."""
3949
result = self.loklak.geocode()

0 commit comments

Comments
 (0)