Cannot create GEFData for unittest

I am writing a unit test for the cpt gef file parser. Because the processing happens external at Viktor, I need to re-create the result object (GEFData). I wrote a result GEFData to a json file. In my unit test, I want to load the json file and re-create the GEFData object. I however get a strange error that I cannot fix. Below is the error, the unittest code and a test json file. Any idea what is happening?

File “viktor\geo.pyx”, line 521, in viktor.geo.GEFData.init
KeyError: ‘headers’

from viktor.geo import GEFData, GEFFile, SoilLayout
import json

with open(Path(__file__).parents[2] / "test_input_data" / "AAHPT-MPT03_gef_data.json", "r") as file:
    mocked_gef_data = json.loads(
    mocked_gef_data_object = GEFData(mocked_gef_data)

Test json data
AAHPT-MPT03_gef_data.json (189.7 KB)

Hi Vincent,

Sorry for the delayed reply, but better late than never: I think the GEFData object trips over the layout of your .json file. I think the GEFData object (normally created directly by the lambda server parsing a GEFFile object) expects the following layout:

{{"headers": {<header fields and values>}, "measurement_data": {<measurement fields and values>}}

In your .json file it seems the top level key is "classification_data", which is unexpected (on the top level "headers" and "measurement_data" are expected). You can remove that top level key and all should work.

Ah, that makes sense. Thanks for the tip. It works now.