oppia/oppia

[Feature Request]: Add tests to fully cover all branches of the backend code.

Open

#21 308 ouverte le 20 nov. 2024

Voir sur GitHub
 (169 commentaires) (0 réactions) (0 assignés)Python (3 534 forks)batch import
HacktoberfestImpact: MediumWork: Lowenhancementgood first issue

Métriques du dépôt

Stars
 (5 292 stars)
Métriques de merge PR
 (Merge moyen 20j 19h) (71 PRs mergées en 30 j)

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 to understand how to run backend tests locally, and how the coverage report (especially for branch coverage) works. (See also the coverage documentation here.)
  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 70->81, 78->80 core/controllers/topics_and_skills_dashboard.py 91->90, 93->90, 589->597
  • core/controllers/profile.py 79->86, 193->200, 581->586, 599->603, 668->662, 843->846 core/controllers/topic_editor.py 510->527, 522->527, 641->647, 794->806 Assignee: @kylie-l
  • core/controllers/reader.py 157->161, 248->250, 1603->1607, 1726->1730, 1739->1749, 1811->1815, 1996->2006, 2389->2399, 2461->2469, 2520->2525, 2521->2525, 2571->2578, 2713->2720
  • core/domain/collection_services.py 721->734, 739->721, 847->772, 858->772, 1170->1165, 1223->exit core/domain/email_manager.py 1200->1197, 1260->exit, 1500->exit, 1551->exit, 2361->2378, 2382->exit, 2462->exit
  • core/domain/draft_upgrade_services.py 172->300, 190->183, 206->202, 261->300, 265->263, 268->266, 280->300, 300->145, 421->405, 433->432, 487->469, 559->514, 907->906, 1019->1018, 1072->1071, 1120->1119, 1182->1181
  • core/domain/exp_domain.py 1035->exit, 1924->1923, 1991->2013, 2101->2097, 2150->2146, 2668->exit, 2702->2717, 2799->2737, 3066->3064, 3070->3061, 3621->3619, 3642->3640, 4297->4287, 4447->4407, 4460->4466, 4470->4407, 6335->6338, 6419->6556, 6440->6445,->6481, 6475->6481, 6478->6481, 6485->6493, 6490->6493, 6498->6503, 6524->6532, 6529->6532, 6536->6541, 6543->6556
  • core/domain/exp_services.py 849->482, 1761->1766, 1806->1801, 3225->3228, 3578->3621, 3615->3621, 3815->exit, 3831->exit, 3928->exit, 3981->4005
  • core/domain/html_cleaner.py 158->150 core/domain/interaction_registry.py 74->65 core/domain/learner_playlist_services.py 129->145, 196->212 core/domain/playthrough_issue_registry.py 68->59, 79->81 core/domain/rte_component_registry.py 124->132, 125->124 core/domain/stats_domain.py 2192->2195, 2195->2199 Assignee: @haani-maybe
  • core/domain/html_validation_service.py 72->exit, 442->430, 455->449, 543->542, 546->542, 1028->1026 core/domain/learner_group_services.py 281->288, 298->297, 317->332, 332->307, 404->402, 453->452, 641->640
  • core/domain/learner_group_fetchers.py 165->175, 198->197, 199->198 core/domain/user_services.py 887->883, 1523->1522, 1693->1691, 2141->exit, 2402->2404, 2840->2846, 2875->exit
  • core/domain/opportunity_services.py 208->216, 337->344, 611->610, 897->exit, 1073->exit core/domain/platform_parameter_domain.py 186->201, 330->334, 357->exit, 358->357, 362->exit
  • core/domain/question_domain.py 609->612, 614->597, 622->711, 644->643, 674->678, 678->673, 1211->1190, 1334->exit, 1364->1379, 1382->1398, 1463->1401, 1712->1716
  • core/domain/question_services.py 361->364, 631->630, 679->630 core/domain/rights_manager.py 132->137, 202->exit, 346->353, 882->886, 1055->1069, 1257->1259 core/domain/skill_domain.py 1722->1725
  • core/domain/skill_services.py @gabriellapost 384->383, 413->412, 481->480, 528->526, 577->575, 579->578, 790->747, 819->747, 941->747, 1084->1083
  • core/domain/state_domain.py 152->160, 585->639, 1226->1245, 1781->1772, 1782->1781, 1806->1800, 1917->1916, 1918->1917, 1919->1918, 1955->1954, 1956->1955, 1957->1956, 2085->2102, 3373->3371, 4484->4514
  • core/domain/stats_services.py 99->107, 605->618, 1468->exit, 1486->exit core/domain/suggestion_registry.py 608->611 core/domain/story_fetchers.py 330->322, 496->495, 518->524, 521->524 core/domain/translation_services.py 166->142
  • core/domain/story_services.py 349->139, 403->139, 430->139, 621->625, 872->885 core/domain/summary_services.py 400->404, 516->515, 790->789 core/domain/translation_domain.py 645->644, 656->655
  • core/domain/topic_services.py 501->243, 545->243, 593->243, 717->716, 727->721, 902->919 core/domain/user_domain.py 1763->exit, 1764->1763 core/domain/user_query_services.py 205->208, 221->225
  • core/domain/rights_domain.py 306->310 core/domain/wipeout_service.py 463->462, 1177->1179, 1186->exit, 1630->1629, 1644->1643, 1657->1655, 1726->1723, 1731->1736, 1737->1736 Assignee: @xiaodis05
  • core/jobs/transforms/validation/base_validation.py 93->exit, 160->exit, 196->exit, 473->exit core/jobs/types/base_validation_errors.py 73->76 core/storage/base_model/gae_models.py 1662->1666 core/storage/collection/gae_models.py 695->exit core/storage/exploration/gae_models.py 826->exit core/storage/question/gae_models.py 573->572 core/storage/topic/gae_models.py 589->exit
  • core/platform/auth/firebase_auth_services.py 390->exit, 453->exit core/platform/bulk_email/mailchimp_bulk_email_services.py 167->exit, 265->271, 301->317 core/platform/taskqueue/cloud_taskqueue_services.py 86->99, 87->94, 106->114 core/platform/taskqueue/cloud_tasks_emulator.py 132->134
  • core/tests/test_utils.py 371->exit, 808->807, 3717->exit, 4052->4057, 4743->exit core/utils.py 227->222, 917->exit, 954->exit main.py 209->211, 1199->1206
  • scripts/check_backend_associated_test_file.py 104->100 scripts/concurrent_task_utils.py 140->146 scripts/linters/js_ts_linter.py 305->353, 331->334, 407->416, 421->403, 507->510 scripts/linters/other_files_linter.py 148->150, 185->202, 199->202
  • scripts/linters/pylint_extensions.py 125->130, 177->181, 600->622, 640->642, 834->744, 2583->2578, 2950->exit scripts/linters/run_lint_checks.py 249->258, 298->295, 400->399 Assignee: @pritesh299 PR: https://github.com/oppia/oppia/pull/24163

In progress

None currently.

  • core/controllers/classroom.py 75->77, 77->74, 89->87, 351->357, 357->366 @Lucy-hi core/controllers/contributor_dashboard.py 219->248, 430->429, 483->489, 553->558, 601->599, 604->595
  • core/domain/action_registry.py 67->59, 78->80 @pritesh299 core/domain/app_feedback_report_domain.py 631->exit, 655->exit, 656->655, 1334->exit, 1491->exit, 1627->1633, 1720->exit, 1968->exit
  • core/domain/learner_progress_services.py 715->exit, 735->exit, 757->exit, 760->exit, 1619->1618, 1623->1618, 1649->1648, 1653->1648 core/domain/recommendations_services.py 341->343, 352->355 @pritesh299
  • scripts/git_changes_utils.py 334->347, 358->360 @pritesh299 scripts/install_dependencies_json_packages.py 292->exit, 304->308, 347->exit, 512->483 scripts/linters/html_linter.py 97->107, 175->163, 270->266, 408->411
  • core/domain/app_feedback_report_services.py 520->529, 674->687, 681->680, 694->696 @pritesh299 core/domain/classroom_config_services.py 343->348 core/domain/beam_job_services.py 147->150 core/domain/blog_domain.py 368->370, 396->exit core/domain/classifier_services.py 515->512, 570->exit
  • scripts/pre_push_hook.py 106->exit, 125->exit, 321->328 scripts/run_e2e_tests.py 129->134, 185->174 scripts/run_frontend_tests.py 117->113, 141->151, 162->165, 206->204, 213->211, 261->267, 296->303 scripts/run_lighthouse_tests.py 300->319, 320->337 scripts/run_mypy_checks.py 184->196 Assignee: @pritesh299
  • core/domain/blog_services.py 777->782, 916->exit, 988->960, 1013->exit, 1069->exit @pritesh299 core/domain/change_domain.py 208->215, 275->282, 283->282 core/domain/event_services.py 112->exit core/domain/feedback_services.py 1247->1245, 1277->1275

Describe alternatives you've considered and rejected

No response

Additional context

No response

Guide contributeur