Risk calculators refactoring
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenQuake Engine |
Fix Released
|
Critical
|
matley |
Bug Description
With the current implementation of risk calculators we have a relevant issue.
It is not easy to implement unit tests. The main reason is because the "units" of the calculators assume that a complete environment has been setup (an hazard job/calculation and a risk job/calculation).
Mocking is not always a viable option (with this implementation) as you often need to mock all the ORM machinery.
Moreover, test execution is a kind of epic, because of the extra computation, as well as disk writing, needed to run a single "unit".
Furthermore, the current celery task accepts too many parameters, making difficult to test every combination of the inputs.
We need to refactor them, such that:
1) reading/writing from the db is separated in specific modules/functions
2) the new units can be tested with a tiny setup (involving few mock objects)
3) the new units have a better function signature (less input params, few output values)
description: | updated |
Changed in oq-engine: | |
importance: | Undecided → Critical |
status: | In Progress → Fix Committed |
Changed in oq-engine: | |
status: | Fix Committed → Fix Released |
https:/ /github. com/gem/ oq-engine/ pull/1164/