[Feature Request]: Add tests to fully cover all branches of the backend code.
Débutant
good first issueenhancementImpact: MediumWork: LowHacktoberfest
6 776 ★
Poids du clone moyen
Mise à jour
Description
### Is your feature request related to a problem? Please describe.
Some branches of the Python backend code are not covered by tests. This results in a coverage report where all lines of backend code are covered, but not all branches are.
We would like to cover all the remaining branches with tests as well. The coverage report contains a `BrPart` column which indicates which branches are not covered. The aim of this issue is to fully cover the branches with missing coverage by writing tests for the given file.
### Instructions for contributors
To claim a sub-issue, please do the following:
1. Read [this wiki page](https://github.com/oppia/oppia/wiki/Backend-tests#run-backend-tests) to understand how to run backend tests locally, and how the coverage report (especially for branch coverage) works. (See also the coverage documentation [here](https://coverage.readthedocs.io/en/latest/branch.html).)
2. Pick one of the checkboxes below and cover all missing branches in the given files (focus on the "BrPart" and "Missing" columns in the coverage log). When you run the backend tests with coverage locally on those files, there should be no missing line or branch coverage shown. **Note that each checkbox covers the file in its line AND the files in the lines below it, up to the next checkbox.**
3. Leave a comment on this issue that specifies which set of files you are claiming, and that shares (a) screenshots or links to the changes you made, (b) a screenshot of the coverage report on your local machine that demonstrates that those files have been fully covered.
Once all files are covered, we should also:
- [ ] Modify scripts/check_overall_backend_test_coverage.py to also verify that there are no uncovered branches, and to fail the coverage check if that happens.
- [ ] Modify the failure message in scripts/check_overall_backend_test_coverage.py to tell contributors how to use the coverage report to determine which lines/branches in their PR still need to be covered.
Note:
- If you run into an `if/elif/else` pattern where the `else` branch is impossible to reach, you can replace the main code with the following instead:
```
if ...:
# do the 'if' stuff
else:
# assert the condition that was previously under the `elif`
# do the 'elif' stuff
```
List of sub-issues:
*Note: Each sub-issue includes a set of files, and the branch coverage as determined on 20 Nov 2024 for each of these files is given. The latter is only provided as an indicator of what needs to be covered, and the code may have changed since then -- the aim is still to have **full coverage** for the files in each set.*
**Unclaimed**
- [ ] core/controllers/acl_decorators.py 4034->4065, 4146->4177, 4728->4733, 4730->4733
core/controllers/admin.py 1299->1302
core/controllers/base.py 422->406
core/controllers/blog_homepage.py 196->204, 294->309, 309->322, 322->327
core/controllers/creator_dashboard.py 235->241, 257->261 @Josmerr
- [ ] core/controllers/editor.py 206->212, 275->282, 819->824, 904->exit, 1549->1557, 1752->1745, 1763->1782, 1769->1782, 1813->1817
core/controllers/suggestion.py 687->690, 907->918, 1298->1296 @Josmerr
- [ ] core/controllers/learner_playlist.py 90->100, 116->120 @sbera01
core/controllers/library.py 76->81, 222->231
core/controllers/payload_validator.py 98->106
core/controllers/practice_sessions.py 137->132
core/controllers/questions_list.py 96->95
core/controllers/skill_editor.py 243->242
core/controllers/story_editor.py 142->141
core/controllers/subtopic_viewer.py
Issues similaires
Tout voir
Python
Débutant
VS Code extension should be robust to YAML parser errors
Seeing this error: ``` Failed to read calkit.yaml: YAMLParseError: A block sequence may not be used as an im…
Mise à jour
Python
Débutant
dash: a manual Refresh control
The dashboard polls: `refreshStats()` (`src/doberman/dash/app.py:408`) every 5 s and `refreshPending()` (`:54…
Mise à jour
Python
Débutant
dash: "Copy details" button on each pending-approval card
Each pending-approval card in the dashboard (`renderPending`, `src/doberman/dash/app.py:448-544`) shows the r…
Mise à jour