Adding a post hook that can run a measurement - try 2#151
Adding a post hook that can run a measurement - try 2#151
Conversation
# Conflicts: # docs/source/user_guide/measure_edition.rst
adding the methods to save/load the file correcting the executions infos # Conflicts: # docs/source/dev_guide/measurement.rst
|
The Travis failing is probably related to some assumption done in the tests about the absence of more tools than the one considered. I have not looked at it in details yet. |
Codecov Report
@@ Coverage Diff @@
## master #151 +/- ##
=========================================
- Coverage 98.38% 97.88% -0.5%
=========================================
Files 157 158 +1
Lines 12293 12366 +73
=========================================
+ Hits 12094 12104 +10
- Misses 199 262 +63 |
| """Post-execusion hook to add a hierarchy of tasks. | ||
|
|
||
| """ | ||
| root_task = Typed(RootTask) |
There was a problem hiding this comment.
All those attributes should be documented using #: comments.
| dependencies = Tuple() | ||
|
|
||
| def __init__(self, declaration, workbench): | ||
| """ Create an empty root task |
There was a problem hiding this comment.
No docstring for __init__ the class docstring is sufficient.
| """ Widget used for the AddTaskHook | ||
|
|
||
| """ | ||
| attr hook |
There was a problem hiding this comment.
Same those deserve a #: comment
| id = 'post-execution' | ||
| point = manifest.id + '.post-execution' | ||
| PostExecutionHook: | ||
| id = 'exopy.addtask_hook' |
There was a problem hiding this comment.
I must say I am not a big fan fan of this name... RunTaskHook perhaps ?
| """Create an AddTaskView. | ||
|
|
||
| """ | ||
| # on est obligé d'aller chercher dans le vrai manifest de measurement pour |
| # assert hook.engine | ||
|
|
||
|
|
||
| def test_get_state(addtaskhook): |
There was a problem hiding this comment.
testing get_state and set_state can be combined to avoid painful manual checking of the config and manual construction of it.
| """ | ||
| addtaskhook.engine = DummyEngine() | ||
| addtaskhook.stop(force=True) | ||
| assert addtaskhook.engine.stop_called == True |
There was a problem hiding this comment.
stop_called does not exist because it was not needed in other tests. You can either edit the dummy or use _stop
| addtaskhook.stop(force=True) | ||
| assert addtaskhook.engine.stop_called == True | ||
|
|
||
| def test_view(addtaskview, addtaskhook): |
There was a problem hiding this comment.
Ideally we would like to show the widget to check it at least displays properly.
| # ca devrait marcher pcq on appelle une seule fois la fixture, ensuite c'est le même objet | ||
| assert rootview.task == addtaskhook.root_task | ||
|
|
||
| def test_list_runtimes(): |
There was a problem hiding this comment.
To test this the easiest way is to monkeypatch the infos of a task to add it a dependencies it does not have you can have a look at tests\tasks\test_dependencies.py.
MatthieuDartiailh
left a comment
There was a problem hiding this comment.
I just looked at the changes not at Travis.
| #: Reference to the root task at the base of the hierarchy | ||
| root_task = Typed(RootTask) | ||
|
|
||
| #: Reference to the measurement workbench |
There was a problem hiding this comment.
application workbench
The workbench is shared by the whole application and is not specific to the measurement plugin.
| #: Reference to the corresponding declaration | ||
| attr declaration | ||
|
|
||
| #: Reference to the corresponding measurement workbench |
| # 'task_id': 'DummyTask'}} | ||
| assert task_prefs # blabla selon sa structure | ||
|
|
||
| assert task_prefs # blabla selon sa structure ? |
There was a problem hiding this comment.
The comment can go away, no ?
MatthieuDartiailh
left a comment
There was a problem hiding this comment.
I looked quickly at Travis failures and left some indications on how to fix them.
| # on est obligé d'aller chercher dans le vrai manifest de measurement pour | ||
| # trouver le make_view | ||
| meas = measurement_workbench.get_plugin('exopy.measurement') | ||
| decl = meas.get_declarations('exopy.addtask_hook') # check how to get the declaration |
There was a problem hiding this comment.
You need to specify that 'exopy.addtask_hook' is a post_hook using the first argument of get_declarations.
| """ | ||
| assert type(addtaskhook.root_task) == RootTask | ||
| assert type(addtaskhook.workbench) == Workbench | ||
| assert type(addtaskhook.dependencies) == Tuple |
There was a problem hiding this comment.
You are mixing the type of the decorator and the type of the value it returns. It should be tuple.
| assert type(addtaskview.widget()[0]) == RootTaskView | ||
| rootview = addtaskview.widget()[0] | ||
| assert rootview.show_path == False | ||
| # ca devrait marcher pcq on appelle une seule fois la fixture, ensuite c'est le même objet |
|
|
||
|
|
||
| @pytest.fixture | ||
| def addtaskhook(measurement): |
There was a problem hiding this comment.
You also need to make sure the TaskPlugin is registered. requesting the task_workbench should work.
As requested in issue #17