Closed pwithnall closed 4 years ago
This is untested (because I don’t know how to test it), and contains TODO
comments. I think the implementation of ParentalControlsChanged
is going to need some discussion: currently it dumps everything in one JSON blob into the database.
I wonder if I should change the client side of it to submit one metric per user account. That would lose us the correlation between user accounts, but allow structured storage of the data (without needing 2+ tables). I don’t really have a grasp of how flexible the data storage needs to be to be queried effectively.
Is https://github.com/endlessm/azafea/blob/master/CONTRIBUTING.md relevant for how to test it?
Is https://github.com/endlessm/azafea/blob/master/CONTRIBUTING.md relevant for how to test it?
Yes, entirely. I evidently failed to run git grep
correctly yesterday to find it. Thanks!
OK, having followed the very clear instructions in CONTRIBUTING.md
, I’ve tested it and the tests are all passing apart from for ParentalControlsChanged
. I think the data storage format for that needs some review/discussion before I put time into fixing the test.
Ready for final review. Tests pass locally for me:
$ podman run --rm --network=host --entrypoint="" azafea-dev pipenv run test
============================= test session starts ==============================
platform linux -- Python 3.7.3, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /opt/azafea/src, inifile: setup.cfg
plugins: cov-2.8.1, flake8-1.0.4, mypy-0.5.0
collected 301 items / 78 deselected / 223 selected
azafea/event_processors/endless/activation/tests/test_activation_parsing.py . [ 0%]
[ 0%]
azafea/event_processors/endless/activation/tests/test_activation_validation.py . [ 0%]
.... [ 2%]
azafea/event_processors/endless/metrics/tests/test_events.py ........... [ 7%]
.................................................. [ 30%]
azafea/event_processors/endless/metrics/tests/test_request.py .. [ 30%]
azafea/event_processors/endless/metrics/tests/test_utils.py ............ [ 36%]
.... [ 38%]
azafea/event_processors/endless/ping/tests/test_ping_parsing.py .. [ 39%]
azafea/event_processors/endless/ping/tests/test_ping_validation.py ..... [ 41%]
[ 41%]
azafea/event_processors/endless/tests/test_image.py .................... [ 50%]
.. [ 51%]
azafea/tests/test_cli.py ............................. [ 64%]
azafea/tests/test_config.py ............................................ [ 83%]
. [ 84%]
azafea/tests/test_controller.py .... [ 86%]
azafea/tests/test_logging.py ... [ 87%]
azafea/tests/test_migrations.py ... [ 88%]
azafea/tests/test_model.py ..... [ 91%]
azafea/tests/test_processor.py ...... [ 93%]
azafea/tests/test_utils.py ......... [ 97%]
azafea/tests/test_vendors.py ..... [100%]
----------- coverage: platform linux, python 3.7.3-final-0 -----------
Name Stmts Miss Branch BrPart Cover Missing
--------------------------------------------------------------------------------------------------------
azafea/__init__.py 0 0 0 0 100%
azafea/cli/__init__.py 31 0 4 1 97% 55->54
azafea/cli/commands.py 119 16 30 2 87% 92->96, 96-113, 125->129, 129-135
azafea/cli/errors.py 10 0 0 0 100%
azafea/config/__init__.py 139 2 36 0 99% 181-183
azafea/config/_validators.py 17 0 10 0 100%
azafea/controller.py 41 5 12 0 83% 65-71
azafea/event_processors/__init__.py 0 0 0 0 100%
azafea/event_processors/endless/__init__.py 0 0 0 0 100%
azafea/event_processors/endless/activation/__init__.py 0 0 0 0 100%
azafea/event_processors/endless/activation/v1/__init__.py 2 0 0 0 100%
azafea/event_processors/endless/activation/v1/cli.py 60 46 16 0 18% 27-39, 43-50, 54-72, 76-102
azafea/event_processors/endless/activation/v1/handler.py 53 4 6 0 93% 86-90
azafea/event_processors/endless/image.py 26 0 6 0 100%
azafea/event_processors/endless/metrics/__init__.py 0 0 0 0 100%
azafea/event_processors/endless/metrics/events/__init__.py 471 16 48 0 93% 810-830, 835-846
azafea/event_processors/endless/metrics/events/_base.py 280 167 56 1 38% 167->168, 168, 232-275, 280-302, 307-372, 376-419, 429-493, 497, 501-537, 541, 545-550, 559, 563-617
azafea/event_processors/endless/metrics/machine.py 38 13 0 0 66% 40-44, 48-52, 56-61, 65-69
azafea/event_processors/endless/metrics/request.py 60 1 2 0 98% 98
azafea/event_processors/endless/metrics/utils.py 34 0 12 0 100%
azafea/event_processors/endless/metrics/v2/__init__.py 2 2 0 0 0% 11-12
azafea/event_processors/endless/metrics/v2/cli.py 280 280 78 0 0% 9-478
azafea/event_processors/endless/metrics/v2/handler.py 28 28 10 0 0% 10-53
azafea/event_processors/endless/ping/__init__.py 0 0 0 0 100%
azafea/event_processors/endless/ping/v1/__init__.py 2 0 0 0 100%
azafea/event_processors/endless/ping/v1/cli.py 71 56 16 0 17% 28-40, 44-72, 76-94, 98-124
azafea/event_processors/endless/ping/v1/handler.py 72 18 8 0 75% 53-79, 124-131
azafea/logging.py 26 0 4 0 100%
azafea/migrations/__init__.py 0 0 0 0 100%
azafea/migrations/env.py 7 7 0 0 0% 13-30
azafea/migrations/utils.py 20 2 4 0 92% 37-39
azafea/model.py 124 27 22 0 76% 76-79, 82-94, 97-100, 103-105, 109-111, 116, 184, 187, 227, 237, 255-258
azafea/processor.py 51 2 6 1 95% 66->67, 67-68
azafea/utils.py 22 0 6 0 100%
azafea/vendors.py 3 0 0 0 100%
--------------------------------------------------------------------------------------------------------
TOTAL 2089 692 392 5 64%
FAIL Required test coverage of 86% not reached. Total coverage: 64.09%
====================== 223 passed, 78 deselected in 3.47s ======================
Code review issues all addressed (thanks!). Tests still pass locally for me. Ready for more review.
Now failing mypy type checks:
=================================== FAILURES ===================================
__________ azafea/event_processors/endless/metrics/events/__init__.py __________
641: error: "Variant" has no attribute "print_"
===================================== mypy =====================================
Found 1 error in 1 file (checked 98 source files)
================ 1 failed, 195 passed, 301 deselected in 10.36s ================
oops, that one’s not part of the unit tests, it’s in a separate lint
job. The print_()
method is actually correct (it’s a pygobject override), but mypy doesn’t seem to be aware of that. Dropping the method and implicitly using __str__()
satisfies mypy and results in a call to print_(True)
in the end (which seems to have the same output for this particular variant).
CR ready again.
Add several new metrics emitted from across the desktop to track how widely parental controls are used and which parental controls settings are used.
Signed-off-by: Philip Withnall withnall@endlessm.com
https://phabricator.endlessm.com/T28742