-
-
Notifications
You must be signed in to change notification settings - Fork 305
add datetime representer and allow unicode characters #2191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
add datetime representer and allow unicode characters #2191
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
def test_admin(monkeypatch, admin_config_path, openapi):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comments above, Thanks!
|
@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 |
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)