TS24501_UEPOL : FGUEPOLStateInd fromJson returned object does not include the optional field 'UEOSId' when present in json
The issue may be reproduced by using the following pytest.
from pycrate_core.repr import show
from pycrate_mobile.TS24501_UEPOL import FGUEPOLStateInd
class TestFguePolStateInd:
def test_fgue_pol_state_ind_from_json_to_obj(self):
fgue_pol_state_ind = FGUEPOLStateInd(val={
'UPSIList': [
{
'PLMN': '27201',
'Cont': [
1,
2
]
},
{
'PLMN': '27201',
'Cont': [
1,
2
]
}],
'UEPolicyCm': {"ANDSPSupp": 0},
'UEOSId': [b'\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10']
})
show(fgue_pol_state_ind)
json = fgue_pol_state_ind.to_json()
print(json)
parsed_fgue_pol_state_ind = FGUEPOLStateInd()
parsed_fgue_pol_state_ind.from_json(json)
show(parsed_fgue_pol_state_ind)
assert parsed_fgue_pol_state_ind.get_val() == fgue_pol_state_ind.get_val()
It seems the json parsing does not take the UEOSId part into account. This is because this IE is optional, and the general behaviour when setting values for such NAS messages is:
- or to set the complete value during initialization: there, values for optional IEs are making those IE as concrete parts of the built message;
- or to set IEs' values 1 by 1: then, optional IEs need to be set concrete explicitely with
set_trans(False).
Currently, the JSON parsing routing follows the same principle. But maybe, as it seems common to use JSON to set entire PDU values all IEs at once (incl. optional ones, and including after class initialization), this could follow a behaviour similar to the binary parser otherwise. I'll check this further later. Thanks for reporting
Commit https://github.com/pycrate-org/pycrate/commit/97d4d7d0b37653d7b45c88ce934799fe42fced98 should solve this issue. Can you give a try with the last tagged release?
@mitshell Thanks the fix and the tag. I'll test as soon as a I can.
@mitshell the unit test above fails as before. Perhaps, i'm not using it correctly. If this is the case, can you please provide an example, thanks.
This should now be fixed with: https://github.com/pycrate-org/pycrate/commit/1520fec7a427ae430138af59149b7de00d175bdc. If you confirm, I can re-tag a minor release.
Thanks @mitshell I've tested and confirmed that the fix works. Much appreciated.
Hi @mitshell Would it be possible to get a new release? Thanks.