add datetime representer and allow unicode characters#2191
add datetime representer and allow unicode characters#2191tomkralidis merged 3 commits intogeopython:masterfrom
Conversation
There was a problem hiding this comment.
Thank you @KatKatKateryna ! 🌟 A couple of things:
- Could you tick the box on "Updates to Public Demo"? I don't think the content of this PR is breaking anything on the demo server 👍🏽
- please run flake8 to fix the formatting of the code: https://docs.pygeoapi.io/en/latest/development.html#using-flake8
- I think this test needs to be adjusted:
pygeoapi/tests/api/test_admin.py
Line 80 in 5d75055
|
@doublebyte1 Thanks! I am not sure about the test, because the only relevant check is for 'put_config' method, but it only checks for the return code. In the end of the method, though, it does call 'admin.write(data)' where the change was made, but the affected function only writes data to YAML and never does any validation from that file. So the only way it would affect the test, is if the yaml writer fails for some reason. |
|
I think the new Yaml dumper is replacing the old one (instead of adding to it), so Path representer seems to be ignored P.S. I rerun the test locally with the latest commit 'add representer...' and these tests are passing now |
|
Thank you @KatKatKateryna |
Overview
This PR is fixing the behavior of overwriting example-config.yaml via admin API. Currently, the data is received correctly but YAML writer is representing datetime objects and special characters incorrectly:

To fix this, YAML writer now has 'allow_unicode=True' and 'Dumper=MyDumper', where MyDumper is an instance of yaml.SafeDumper with correct datetime object representers.
Related Issue / discussion
This was discovered while working on QGIS pygeoapi-config plugin: correctly sent data is being saved incorrectly on the running pygeoapi instance: byteroad/pygeoapi_config#12
Additional information
Dependency policy (RFC2)
Updates to public demo
Contributions and licensing
(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)