question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fix tests/methods that refer to private functions in Python

See original GitHub issue

There are currently a few tests that reference private functions in Python. Tests should test through public interface. If the test tests a private method, find a way to test the method through the existing public interface instead (you’ll need to find the corresponding public API function that uses the internal private one, and use that function instead in tests). Please note that modifications to other classes outside of the file in question may be necessary.

Note that you can identify such references by searching for the string # pylint: disable=protected-access. (If you don’t see the string in the file(s) you’re assigned to, please let the author of this issue know so that the list can be edited accordingly.)

Important: In general, do not just change methods from private to public. You’ll need to find the already existing publicly-accessible function which invokes the private method and use that one instead.

The following the cases where we test private functions:

  • gae_models.VersionedModel @Azrecycle4
    • delete
    • revert
    • get_version
    • get_multi_versions
    • get_snapshots_metadata
  • suggestion_services_test.SuggestionServicesUnitTests @gopivaibhav
    • test_accept_suggestion_commit_message_after_updating_a_suggestion
    • test_update_translation_suggestion_to_change_translation_html
  • suggestion_services_test.SuggestionIntegrationTests @hardikkat24
    • setUp
  • email_manager_test.EmailRightsTest @vijaykpatel
    • test_sender_id_validation
  • email_manager.BulkEmailsTests @brianlinUM
    • test_that_correct_email_is_sent
    • test_that_exception_is_raised_for_unauthorised_sender
  • library_test.LibraryPageTests @brianlinUM
    • test_library_handler_for_created_explorations
  • build_test (All) @Mohitbalwani26
  • suggestion_test.SuggestionUnitTests @AnuragVats007
    • setUp
  • exp_services_test.ZipFileExportUnitTests (all) @ayushjaink8

Completed:

  • draft_upgrade_services_test.DraftUpgradeUnitTests @kaylahardie
    • test_try_upgrade_success
  • draft_upgrade_services_test.DraftUpgradeUtilUnitTests @kaylahardie
    • test_convert_states_v29_dict_to_v30_dict
    • test_convert_states_v28_dict_to_v29_dict
    • test_convert_states_v27_dict_to_v28_dict
  • gae_models_test.GenerateHashTests - @lorryaze
    • test_same_inputs_always_gives_same_hashes
    • test_different_inputs_give_different_hashes
  • models_test.BaseCalculationUnitTests @donosco98 (#7841)
    • test_equality_of_hashable_answers
  • user_services_test.LastLoginIntegrationTests @vpishuk
    • test_legacy_user
  • user_services_test.LastExplorationEditedIntegrationTests @vpishuk
    • test_legacy_user
    • test_last_exp_edit_time_gets_updated
  • user_services_test.LastExplorationCreatedIntegrationTests @vpishuk
    • test_legacy_user
    • test_last_exp_edit_time_gets_updated
  • config_domain_test.ConfigPropertyRegistryTests (@nishantwrp)
    • test_config_property_schemas_are_valid
  • email_manager.DuplicateEmailTests @Hudda
    • test_send_email_does_not_resend_if_same_hash_exists
    • test_sending_email_with_different_recipient_but_same_hash
    • test_sending_email_with_different_subject_but_same_hash
    • test_sending_email_with_different_body_but_same_hash
    • test_duplicate_emails_are_sent_after_some_time_has_elapsed
  • user_jobs_one_off_test.UserFirstContributionMsecOneOffJobTests - @Arnesh07
    • test_contribution_msec_does_not_update_on_unpublished_explorations
  • user_jobs_one_off_test.UserLastExplorationActivityOneOffJobTests @Hudda
    • test_that_last_created_time_is_updated
  • html_validation_service_test.ContentMigrationTests - @cathuang20
    • test_validate_soup_for_rte
    • test_validate_customization_args_in_tag
    • test_that_last_edited_time_is_updated
    • test_that_last_edited_and_created_time_both_updated
    • test_that_last_edited_and_created_time_are_not_updated
  • rte_component_registry_test.RteComponentUnitTests - @alexlee311
    • test_rte_components_are_valid
  • extensions.interactions.base_test.InteractionUnitTests - @aazuspan
    • test_default_interactions_are_valid
  • collection_services_test @sudiptapradhan1181
    • _count_at_least_editable_collection_summaries
  • exp_services.test - @aazuspan
    • _count_at_least_editable_exploration_summaries

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:145 (124 by maintainers)

github_iconTop GitHub Comments

1reaction
ZhanLiangUFcommented, Nov 5, 2021

@vojtechjelinek Can you unassign me from SuggestionServicesUnitTests? Thank you.

1reaction
sajalasaticommented, Apr 6, 2021

@kevinlee12 Are you still actively tracking this issue? If not we can drop the talk-to: @kevinlee12 label.

I’m no longer actively contributing to this project; however, I’m happy to provide any historical context for when I was active. So to answer your question, no I’m no longer tracking this issue nor any issues within the project.

@kevinlee12 Thanks a lot for the update and for letting us know we can reach out to you when needed 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Private Methods in Python - GeeksforGeeks
This is what private methods are used for. It is used to hide the inner functionality of any class from the outside world....
Read more >
How do you correctly use private functions in Python? [duplicate]
The error message is telling you that the object called self is an instance of class matrix ; but it has no attribute...
Read more >
Rules and regulations of Python private method - eduCBA
Guide to Python Private Method. Here we discuss the Advantages along with the Rules and regulations for Python private method.
Read more >
Private Methods in Python | FavTutor
Encapsulation is one of the important concepts in object-oriented programming. It refers to the idea of wrapping the data and the methods ......
Read more >
Why is unit testing private methods considered as bad practice?
I am currently working on a small project in Python. I commonly structure my classes with some public methods that are documented but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found