Skip to content
Browse files
basic tests for json type in gpkg
  • Loading branch information
signedav committed Dec 11, 2018
1 parent 5526975 commit 607dffd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
@@ -1230,6 +1230,29 @@ def testTransaction(self):
self.assertEqual(len([f for f in vl2_external.getFeatures(QgsFeatureRequest())]), 1)
del vl2_external

def testJson(self):
tmpfile = os.path.join(self.basetestpath, 'test_json.gpkg')
testdata_path = unitTestDataPath('provider')
shutil.copy(os.path.join(unitTestDataPath('provider'), 'test_json.gpkg'), tmpfile)

vl = QgsVectorLayer('{}|layerid=0'.format(tmpfile, 'foo', 'ogr'))

fields = vl.dataProvider().fields()
self.assertEqual('json_content')).type(), QVariant.Map)

fi = vl.getFeatures(QgsFeatureRequest())
f = QgsFeature()

#test dict value
while fi.nextFeature(f):
fid = vl.fields().lookupField('fid')
if fid == 1:
value = vl.fields().lookupField('json_content')
self.assertIsInstance(f.attributes()[value], dict)
self.assertEqual(f.attributes()[value_idx], {'foo': 'bar'})

if __name__ == '__main__':
Binary file not shown.

0 comments on commit 607dffd

Please sign in to comment.