input
stringlengths
11
7.65k
target
stringlengths
22
8.26k
def __init__(self,params,parent): self.params=params self.parent=parent
def __init__(self): self.var = 1 # self.var will be overwritten C.__init__(self)
def __init__(self,params,parent): self.params=params self.parent=parent
def __init__(self): self.var = 0 # self.var will be overwritten
def __init__(self,params,parent): self.params=params self.parent=parent
def make_new_rsa_key_weak(bits): return RSA.generate(bits) # NOT OK
def __init__(self,params,parent): self.params=params self.parent=parent
def _build_gravatar_url(email, params): """Generate a Gravatar URL.
def __init__(self,params,parent): self.params=params self.parent=parent
def make_new_rsa_key_strong(bits): return RSA.generate(bits) # OK
def __init__(self,params,parent): self.params=params self.parent=parent
def __init__(self, email, params): self.email = email self.params = params
def __init__(self,params,parent): self.params=params self.parent=parent
def render(self, context): try: if self.params: params = template.Variable(self.params).resolve(context) else: params = {} # try matching an address string literal email_literal = self.email.strip().lower() if EMAIL_RE....
def __init__(self,params,parent): self.params=params self.parent=parent
def __init__(self): # pylint: disable=super-init-not-called pass
def __init__(self,params,parent): self.params=params self.parent=parent
def test_parse_sections(): simple_mariofile_sections = dict(mariofile.parse_sections(SIMPLE_MARIOFILE.splitlines(True))) assert len(simple_mariofile_sections) == 3 complex_mariofile_sections = dict(mariofile.parse_sections(COMPLEX_MARIOFILE.splitlines(True))) assert len(complex_mariofile_sections) == 2 ...
def __init__(self,params,parent): self.params=params self.parent=parent
def setUp(self): super(BaseSuggestionUnitTests, self).setUp() self.base_suggestion = MockInvalidSuggestion()
def __init__(self,params,parent): self.params=params self.parent=parent
def test_statements(): with pytest.raises(mariofile.ConfigurationFileError): mariofile.parse_section_body(CRASH_MARIOFILE_1.splitlines()) with pytest.raises(mariofile.ConfigurationFileError): mariofile.parse_section_body(CRASH_MARIOFILE_2.splitlines())
def __init__(self,params,parent): self.params=params self.parent=parent
def test_base_class_accept_raises_error(self): with self.assertRaisesRegex( NotImplementedError, 'Subclasses of BaseSuggestion should implement accept.'): self.base_suggestion.accept()
def __init__(self,params,parent): self.params=params self.parent=parent
def test_parse_statements(): parsed_statement = mariofile.parse_statements(STRING_PARSE_STATEMENTS.splitlines()) assert '\n'.join(parsed_statement) == "statement\nstatement con commento"
def __init__(self,params,parent): self.params=params self.parent=parent
def test_base_class_get_change_list_for_accepting_suggestion_raises_error( self): with self.assertRaisesRegex( NotImplementedError, 'Subclasses of BaseSuggestion should implement ' 'get_change_list_for_accepting_suggestion.'): self.base_suggestion.get_...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_parse_section_body(): output_section = { 'action_template': ' task', 'sources_repls': 'source', 'variable': '6', 'target_pattern': 'target', } assert mariofile.parse_section_body(SECTION.splitlines(True)) == output_section with pytest.raises(mariofile.Configur...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_base_class_pre_accept_validate_raises_error(self): with self.assertRaisesRegex( NotImplementedError, 'Subclasses of BaseSuggestion should implement' ' pre_accept_validate.'): self.base_suggestion.pre_accept_validate()
def __init__(self,params,parent): self.params=params self.parent=parent
def test_parse_include(): filepaths, current_line = mariofile.parse_include(INCLUDE_FILE.splitlines(True)) assert filepaths == ['prova.ini', 'altrofile.ini'] assert current_line == 4 filepaths, current_line = mariofile.parse_include(INCLUDE_UNIQUE_FILE.splitlines(True)) assert filepaths == ['prova.i...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_base_class_populate_old_value_of_change_raises_error(self): with self.assertRaisesRegex( NotImplementedError, 'Subclasses of BaseSuggestion should implement' ' populate_old_value_of_change.'): self.base_suggestion.populate_old_value_of_change()
def __init__(self,params,parent): self.params=params self.parent=parent
def test_base_class_pre_update_validate_raises_error(self): with self.assertRaisesRegex( NotImplementedError, 'Subclasses of BaseSuggestion should implement' ' pre_update_validate.'): self.base_suggestion.pre_update_validate({})
def __init__(self,params,parent): self.params=params self.parent=parent
def test_base_class_get_all_html_content_strings(self): with self.assertRaisesRegex( NotImplementedError, 'Subclasses of BaseSuggestion should implement' ' get_all_html_content_strings.'): self.base_suggestion.get_all_html_content_strings()
def __init__(self,params,parent): self.params=params self.parent=parent
def test_base_class_get_target_entity_html_strings(self): with self.assertRaisesRegex( NotImplementedError, 'Subclasses of BaseSuggestion should implement' ' get_target_entity_html_strings.'): self.base_suggestion.get_target_entity_html_strings()
def __init__(self,params,parent): self.params=params self.parent=parent
def setUp(self): super(SuggestionEditStateContentUnitTests, self).setUp() self.signup(self.AUTHOR_EMAIL, 'author') self.author_id = self.get_user_id_from_email(self.AUTHOR_EMAIL) self.signup(self.REVIEWER_EMAIL, 'reviewer') self.reviewer_id = self.get_user_id_from_email(self.REV...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_create_suggestion_edit_state_content(self): expected_suggestion_dict = self.suggestion_dict observed_suggestion = suggestion_registry.SuggestionEditStateContent( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_sugge...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_get_score_part_helper_methods(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionEditStateContent( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict['targ...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validate_target_version_at_submission(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionEditStateContent( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dic...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validate_author_id_format(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionEditStateContent( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict['target_ve...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validate_final_reviewer_id_format(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionEditStateContent( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict['t...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_populate_old_value_of_change_with_invalid_state(self): self.save_new_default_exploration('exp1', self.author_id) expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionEditStateContent( expected_suggestion_dict['suggestion_id'], ...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_pre_update_validate_change_new_value(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionEditStateContent( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_convert_html_in_suggestion_change(self): html_content = ( '<p>Value</p><oppia-noninteractive-math raw_latex-with-value="&a' 'mp;quot;+,-,-,+&amp;quot;"></oppia-noninteractive-math>') expected_html_content = ( '<p>Value</p><oppia-noninteractive-math math_conte...
def __init__(self,params,parent): self.params=params self.parent=parent
def setUp(self): super(SuggestionTranslateContentUnitTests, self).setUp() self.signup(self.AUTHOR_EMAIL, 'author') self.author_id = self.get_user_id_from_email(self.AUTHOR_EMAIL) self.signup(self.REVIEWER_EMAIL, 'reviewer') self.reviewer_id = self.get_user_id_from_email(self.REV...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_create_suggestion_add_translation(self): expected_suggestion_dict = self.suggestion_dict observed_suggestion = suggestion_registry.SuggestionTranslateContent( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggesti...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_get_score_part_helper_methods(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionTranslateContent( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict['targ...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validate_author_id(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionTranslateContent( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict['target_version_a...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validate_author_id_format(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionTranslateContent( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict['target_ve...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_pre_accept_validate_state_name(self): self.save_new_default_exploration('exp1', self.author_id) expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionTranslateContent( expected_suggestion_dict['suggestion_id'], expected_sugges...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_accept_suggestion_adds_translation_in_exploration(self): self.save_new_default_exploration('exp1', self.author_id) exploration = exp_fetchers.get_exploration_by_id('exp1') self.assertEqual(exploration.get_translation_counts(), {}) suggestion = suggestion_registry.SuggestionTrans...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_accept_suggestion_with_set_of_string_adds_translation(self): self.save_new_default_exploration('exp1', self.author_id) exploration = exp_fetchers.get_exploration_by_id('exp1') self.assertEqual(exploration.get_translation_counts(), {}) suggestion = suggestion_registry.SuggestionT...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_accept_suggestion_with_psedonymous_author_adds_translation(self): self.save_new_default_exploration('exp1', self.author_id) exploration = exp_fetchers.get_exploration_by_id('exp1') self.assertEqual(exploration.get_translation_counts(), {}) expected_suggestion_dict = self.sugge...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_convert_html_in_suggestion_change(self): html_content = ( '<p>Value</p><oppia-noninteractive-math raw_latex-with-value="&a' 'mp;quot;+,-,-,+&amp;quot;"></oppia-noninteractive-math>') expected_html_content = ( '<p>Value</p><oppia-noninteractive-math math_conte...
def __init__(self,params,parent): self.params=params self.parent=parent
def setUp(self): super(SuggestionAddQuestionTest, self).setUp() self.signup(self.AUTHOR_EMAIL, 'author') self.author_id = self.get_user_id_from_email(self.AUTHOR_EMAIL) self.signup(self.REVIEWER_EMAIL, 'reviewer') self.reviewer_id = self.get_user_id_from_email(self.REVIEWER_EMAI...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_create_suggestion_add_question(self): expected_suggestion_dict = self.suggestion_dict observed_suggestion = suggestion_registry.SuggestionAddQuestion( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict[...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_get_score_part_helper_methods(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionAddQuestion( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict['target_ve...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validate_score_type(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionAddQuestion( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict['target_version_at_s...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validate_change_question_dict(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionAddQuestion( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict['target_ve...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validate_change_question_state_data_schema_version(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionAddQuestion( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_sugge...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validate_change_skill_difficulty_none(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionAddQuestion( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict['ta...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validate_change_skill_difficulty_invalid_value(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionAddQuestion( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_pre_accept_validate_change_skill_id(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionAddQuestion( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict['tar...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_pre_accept_validate_change_invalid_skill_id(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionAddQuestion( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_d...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_get_change_list_for_accepting_suggestion(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionAddQuestion( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_populate_old_value_of_change(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionAddQuestion( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict['target_ver...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_cannot_accept_suggestion_with_invalid_skill_id(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionAddQuestion( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestio...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_pre_update_validate_change_cmd(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionAddQuestion( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict['target_v...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_pre_update_validate_change_skill_id(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionAddQuestion( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict['tar...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_pre_update_validate_complains_if_nothing_changed(self): change = { 'cmd': question_domain.CMD_CREATE_NEW_FULLY_SPECIFIED_QUESTION, 'question_dict': { 'question_state_data': self._create_valid_question_data( 'default_state').to_dict(), ...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_pre_update_validate_accepts_a_change_in_skill_difficulty_only( self): change = { 'cmd': question_domain.CMD_CREATE_NEW_FULLY_SPECIFIED_QUESTION, 'question_dict': { 'question_state_data': self._create_valid_question_data( 'default_s...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_pre_update_validate_accepts_a_change_in_state_data_only(self): change = { 'cmd': question_domain.CMD_CREATE_NEW_FULLY_SPECIFIED_QUESTION, 'question_dict': { 'question_state_data': self._create_valid_question_data( 'default_state').to_dict(), ...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validate_author_id(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionAddQuestion( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict['target_version_at_sub...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validate_author_id_format(self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionAddQuestion( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], expected_suggestion_dict['target_version...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validate_language_code_fails_when_language_codes_do_not_match( self): expected_suggestion_dict = self.suggestion_dict suggestion = suggestion_registry.SuggestionAddQuestion( expected_suggestion_dict['suggestion_id'], expected_suggestion_dict['target_id'], ...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_convert_html_in_suggestion_change(self): html_content = ( '<p>Value</p><oppia-noninteractive-math raw_latex-with-value="&a' 'mp;quot;+,-,-,+&amp;quot;"></oppia-noninteractive-math>') expected_html_content = ( '<p>Value</p><oppia-noninteractive-math math_conte...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_accept_suggestion_with_images(self): html_content = ( '<p>Value</p><oppia-noninteractive-math math_content-with-value=' '"{&amp;quot;raw_latex&amp;quot;: &amp;quot;+,-,-,+&amp;quot;, &' 'amp;quot;svg_filename&amp;quot;: &amp;quot;img.svg&amp;quot;}">' '</...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_accept_suggestion_with_image_region_interactions(self): with utils.open_file( os.path.join(feconf.TESTS_DATA_DIR, 'img.png'), 'rb', encoding=None) as f: original_image_content = f.read() fs_services.save_original_and_compressed_versions_of_image( ...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_contructor_updates_state_shema_in_change_cmd(self): score_category = ( suggestion_models.SCORE_TYPE_QUESTION + suggestion_models.SCORE_CATEGORY_DELIMITER + 'skill_id') change = { 'cmd': ( question_domain .CMD_CREATE_NEW_FULLY_S...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_contructor_raise_exception_for_invalid_state_shema_version(self): score_category = ( suggestion_models.SCORE_TYPE_QUESTION + suggestion_models.SCORE_CATEGORY_DELIMITER + 'skill_id') change = { 'cmd': ( question_domain .CMD_CREA...
def __init__(self,params,parent): self.params=params self.parent=parent
def setUp(self): super(BaseVoiceoverApplicationUnitTests, self).setUp() self.base_voiceover_application = MockInvalidVoiceoverApplication()
def __init__(self,params,parent): self.params=params self.parent=parent
def test_base_class_init_raises_error(self): with self.assertRaisesRegex( NotImplementedError, 'Subclasses of BaseVoiceoverApplication should implement ' '__init__.'): suggestion_registry.BaseVoiceoverApplication()
def __init__(self,params,parent): self.params=params self.parent=parent
def test_base_class_accept_raises_error(self): with self.assertRaisesRegex( NotImplementedError, 'Subclasses of BaseVoiceoverApplication should implement accept.'): self.base_voiceover_application.accept()
def __init__(self,params,parent): self.params=params self.parent=parent
def test_base_class_reject_raises_error(self): with self.assertRaisesRegex( NotImplementedError, 'Subclasses of BaseVoiceoverApplication should implement reject.'): self.base_voiceover_application.reject()
def __init__(self,params,parent): self.params=params self.parent=parent
def setUp(self): super(ExplorationVoiceoverApplicationUnitTest, self).setUp() self.signup('author@example.com', 'author') self.author_id = self.get_user_id_from_email('author@example.com') self.signup('reviewer@example.com', 'reviewer') self.reviewer_id = self.get_user_id_from_e...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validation_for_handled_application_with_invalid_final_review(self): self.assertEqual( self.voiceover_application.status, suggestion_models.STATUS_IN_REVIEW) self.assertEqual(self.voiceover_application.final_reviewer_id, None) self.voiceover_application.validate()...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validation_for_rejected_application_with_no_message(self): self.assertEqual( self.voiceover_application.status, suggestion_models.STATUS_IN_REVIEW) self.assertEqual(self.voiceover_application.rejection_message, None) self.voiceover_application.validate() ...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validation_with_invalid_language_code_type_raise_exception(self): self.assertEqual(self.voiceover_application.language_code, 'en') self.voiceover_application.validate() self.voiceover_application.language_code = 1 with self.assertRaisesRegex( utils.ValidationError, ...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_to_dict_returns_correct_dict(self): self.voiceover_application.accept(self.reviewer_id) expected_dict = { 'voiceover_application_id': 'application_id', 'target_type': 'exploration', 'target_id': 'exp_id', 'status': 'accepted', 'author_...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_is_handled_property_returns_correct_value(self): self.assertFalse(self.voiceover_application.is_handled) self.voiceover_application.accept(self.reviewer_id) self.assertTrue(self.voiceover_application.is_handled)
def __init__(self,params,parent): self.params=params self.parent=parent
def test_accept_voiceover_application(self): self.assertEqual(self.voiceover_application.final_reviewer_id, None) self.assertEqual(self.voiceover_application.status, 'review') self.voiceover_application.accept(self.reviewer_id) self.assertEqual( self.voiceover_application.f...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_reject_voiceover_application(self): self.assertEqual(self.voiceover_application.final_reviewer_id, None) self.assertEqual(self.voiceover_application.status, 'review') self.voiceover_application.reject(self.reviewer_id, 'rejection message') self.assertEqual( self.vo...
def __init__(self,params,parent): self.params=params self.parent=parent
def _assert_community_contribution_stats_is_in_default_state(self): """Checks if the community contribution stats is in its default state. """ community_contribution_stats = ( suggestion_services.get_community_contribution_stats() ) self.assertEqual( ...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_initial_object_with_valid_arguments_has_correct_properties(self): community_contribution_stats = ( suggestion_registry.CommunityContributionStats( self.translation_reviewer_counts_by_lang_code, self.translation_suggestion_counts_by_lang_code, ...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_set_translation_reviewer_count_for_lang_code_adds_new_lang_key( self): community_contribution_stats = ( suggestion_services.get_community_contribution_stats() ) self._assert_community_contribution_stats_is_in_default_state() ( community_contri...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_get_translation_language_codes_that_need_reviewers_for_one_lang( self): stats = suggestion_services.get_community_contribution_stats() stats.set_translation_suggestion_count_for_language_code( self.sample_language_code, 1) language_codes_that_need_reviewers = ( ...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_get_translation_language_codes_that_need_reviewers_for_multi_lang( self): stats = suggestion_services.get_community_contribution_stats() stats.set_translation_suggestion_count_for_language_code('hi', 1) stats.set_translation_suggestion_count_for_language_code('fr', 1) ...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_get_translation_language_codes_that_need_reviewers_for_no_lang( self): stats = suggestion_services.get_community_contribution_stats() language_codes_that_need_reviewers = ( stats.get_translation_language_codes_that_need_reviewers() ) self.assertEqual( ...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_question_reviewers_are_needed_if_suggestions_zero_reviewers( self): stats = suggestion_services.get_community_contribution_stats() stats.question_suggestion_count = 1 self.assertTrue(stats.are_question_reviewers_needed())
def __init__(self,params,parent): self.params=params self.parent=parent
def test_question_reviewers_are_needed_if_num_suggestions_past_max(self): stats = suggestion_services.get_community_contribution_stats() stats.question_suggestion_count = 2 stats.question_reviewer_count = 1 config_services.set_property( 'committer_id', 'max_number_of_suggesti...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_question_reviewers_not_needed_if_num_suggestions_eqs_max(self): stats = suggestion_services.get_community_contribution_stats() stats.question_suggestion_count = 2 stats.question_reviewer_count = 2 config_services.set_property( 'committer_id', 'max_number_of_suggestio...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_question_reviewers_not_needed_if_num_suggestions_less_max(self): stats = suggestion_services.get_community_contribution_stats() stats.question_suggestion_count = 1 stats.question_reviewer_count = 2 config_services.set_property( 'committer_id', 'max_number_of_suggesti...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_question_reviewers_not_needed_if_no_reviewers_no_sugestions( self): stats = suggestion_services.get_community_contribution_stats() self._assert_community_contribution_stats_is_in_default_state() self.assertFalse(stats.are_question_reviewers_needed())
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validate_question_reviewer_count_fails_for_negative_count(self): community_contribution_stats = ( suggestion_services.get_community_contribution_stats() ) community_contribution_stats.question_reviewer_count = ( self.negative_count ) with self.as...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validate_question_suggestion_count_fails_for_negative_count(self): community_contribution_stats = ( suggestion_services.get_community_contribution_stats() ) community_contribution_stats.question_suggestion_count = ( self.negative_count ) with sel...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validate_question_reviewer_count_fails_for_non_integer_count( self): community_contribution_stats = ( suggestion_services.get_community_contribution_stats() ) community_contribution_stats.question_reviewer_count = ( self.non_integer_count ) ...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_validate_question_suggestion_count_fails_for_non_integer_count( self): community_contribution_stats = ( suggestion_services.get_community_contribution_stats() ) community_contribution_stats.question_suggestion_count = ( self.non_integer_count ...
def __init__(self,params,parent): self.params=params self.parent=parent
def main(unused_argv): tpu_cluster_resolver = contrib_cluster_resolver.TPUClusterResolver( FLAGS.tpu, zone=FLAGS.tpu_zone, project=FLAGS.gcp_project) config = contrib_tpu.RunConfig( cluster=tpu_cluster_resolver, model_dir=FLAGS.model_dir, save_checkpoints_steps=FLAGS.iterations_per_loop, ...
def __init__(self,params,parent): self.params=params self.parent=parent
def test_telemetry_finish(runner, live_mock_server, parse_ctx): with runner.isolated_filesystem(): run = wandb.init() run.finish() ctx_util = parse_ctx(live_mock_server.get_ctx()) telemetry = ctx_util.telemetry assert telemetry and 2 in telemetry.get("3", [])
def __init__(self,params,parent): self.params=params self.parent=parent
def allowed_file(filename): return '.' in filename and \ filename.rsplit('.', 1)[1] in app.config.get('ALLOWED_EXTENSIONS')
def __init__(self,params,parent): self.params=params self.parent=parent
def test_telemetry_imports_hf(runner, live_mock_server, parse_ctx): with runner.isolated_filesystem(): run = wandb.init() with mock.patch.dict("sys.modules", {"transformers": mock.Mock()}): import transformers run.finish() ctx_util = parse_ctx(live_mock_server....
def __init__(self,params,parent): self.params=params self.parent=parent
def unique_name(): now_time = datetime.datetime.now().strftime("%Y%m%d%H%M%S") random_num = random.randint(0, 100) if random_num <= 10: random_num = str(0) + str(random_num) unique_num = str(now_time) + str(random_num) return unique_num
def __init__(self,params,parent): self.params=params self.parent=parent
def test_telemetry_imports_catboost(runner, live_mock_server, parse_ctx): with runner.isolated_filesystem(): with mock.patch.dict("sys.modules", {"catboost": mock.Mock()}): import catboost run = wandb.init() run.finish() ctx_util = parse_ctx(live_mock_server...
def __init__(self,params,parent): self.params=params self.parent=parent
def image_thumbnail(filename): filepath = os.path.join(app.config.get('UPLOAD_FOLDER'), filename) im = Image.open(filepath) w, h = im.size if w > h: im.thumbnail((106, 106*h/w)) else: im.thumbnail((106*w/h, 106)) im.save(os.path.join(app.config.get('UPLOAD_FOLDER'), os...