Skip to content
Permalink
Browse files

json decoding of values

before comparing them with the python structs
  • Loading branch information
signedav committed Oct 18, 2018
1 parent d34fdf2 commit 7026dfa329d58fcabe05d60ab0f1ac454db27471
Showing with 15 additions and 12 deletions.
  1. +15 −12 tests/src/python/test_qgsserver_wms_getfeatureinfo.py
@@ -26,6 +26,9 @@
import urllib.parse
import urllib.error

import xml.etree.ElementTree as ET
import json

from qgis.testing import unittest
from qgis.PyQt.QtCore import QSize

@@ -439,13 +442,13 @@ def testGetFeatureInfoPostgresTypes(self):
root = ET.fromstring(response_body)
for attribute in root.iter('Attribute'):
if attribute.get('name') == 'jvalue':
self.assertIsInstance(attribute.get('value'), list)
self.assertEqual(attribute.get('value'), [1, 2, 3])
self.assertEqual(attribute.get('value'), [1.0, 2.0, 3.0])
self.assertIsInstance(json.loads(attribute.get('value')), list)
self.assertEqual(json.loads(attribute.get('value')), [1, 2, 3])
self.assertEqual(json.loads(attribute.get('value')), [1.0, 2.0, 3.0])
if attribute.get('name') == 'jbvalue':
self.assertIsInstance(attribute.get('value'), list)
self.assertEqual(attribute.get('value'), [4, 5, 6])
self.assertEqual(attribute.get('value'), [4.0, 5.0, 6.0])
self.assertIsInstance(json.loads(attribute.get('value')), list)
self.assertEqual(json.loads(attribute.get('value')), [4, 5, 6])
self.assertEqual(json.loads(attribute.get('value')), [4.0, 5.0, 6.0])

#compare decoded json field dict
response_header, response_body, query_string = self.wms_request('GetFeatureInfo',
@@ -458,13 +461,13 @@ def testGetFeatureInfoPostgresTypes(self):
root = ET.fromstring(response_body)
for attribute in root.iter('Attribute'):
if attribute.get('name') == 'jvalue':
self.assertIsInstance(attribute.get('value'), dict)
self.assertEqual(attribute.get('value'), {'a': 1, 'b': 2})
self.assertEqual(attribute.get('value'), {'a': 1.0, 'b': 2.0})
self.assertIsInstance(json.loads(attribute.get('value')), dict)
self.assertEqual(json.loads(attribute.get('value')), {'a': 1, 'b': 2})
self.assertEqual(json.loads(attribute.get('value')), {'a': 1.0, 'b': 2.0})
if attribute.get('name') == 'jbvalue':
self.assertIsInstance(attribute.get('value'), dict)
self.assertEqual(attribute.get('value'), {'c': 4, 'd': 5})
self.assertEqual(attribute.get('value'), {'c': 4.0, 'd': 5.0})
self.assertIsInstance(json.loads(attribute.get('value')), dict)
self.assertEqual(json.loads(attribute.get('value')), {'c': 4, 'd': 5})
self.assertEqual(json.loads(attribute.get('value')), {'c': 4.0, 'd': 5.0})

if __name__ == '__main__':
unittest.main()

0 comments on commit 7026dfa

Please sign in to comment.
You can’t perform that action at this time.