def exit_application(self, widget, event): strtrue = str(True) save_vocables = AppSettings.get_setting_by_name( AppSettings.SAVE_VOCABLES_ON_EXIT_SETTING_NAME) == strtrue show_dialog = AppSettings.get_setting_by_name( AppSettings.DIALOG_SHOW_SAVE_VOCABLES_CONFIRMATION_SETTING_NAME ) == strtrue if show_dialog and VocableManager.vocables_changed: save_vocables_confirmation_dialog = SaveVocablesBeforeExitConfirmationDialog( self) save_vocables = save_vocables_confirmation_dialog.run( ) == Gtk.ResponseType.YES AppSettings.change_setting_by_name( AppSettings.SAVE_VOCABLES_ON_EXIT_SETTING_NAME, save_vocables) save_vocables_confirmation_dialog.destroy() if save_vocables: VocableManager.save_vocables(VocableManager.vocables) exit_on_exit_confirmation = AppSettings.get_setting_by_name( AppSettings.EXIT_ON_EXIT_SETTING_NAME) == strtrue show_exit_confirmation = AppSettings.get_setting_by_name( AppSettings.DIALOG_SHOW_EXIT_CONFIRMATION_SETTING_NAME) if show_exit_confirmation == strtrue: ExitConfirmationDialog.__init__ = timefunction( ExitConfirmationDialog.__init__) # decoration exit_confirmation_dialog = ExitConfirmationDialog(self) exit_confirmation_dialog.run = timefunction( exit_confirmation_dialog.run) # decoration exit_on_exit_confirmation = exit_confirmation_dialog.run( ) == Gtk.ResponseType.YES AppSettings.change_setting_by_name( AppSettings.EXIT_ON_EXIT_SETTING_NAME, exit_on_exit_confirmation) exit_confirmation_dialog.destroy() if exit_on_exit_confirmation: # print("Clicked YES") AppSettings.save_settings() Gtk.main_quit() sys.exit() else: # print("Clicked NO") pass return GTKSignal.DO_NOT_PROPAGATE
def exit_application(self, widget, event): strtrue = str(True) save_vocables = AppSettings.get_setting_by_name(AppSettings.SAVE_VOCABLES_ON_EXIT_SETTING_NAME) == strtrue show_dialog = AppSettings.get_setting_by_name( AppSettings.DIALOG_SHOW_SAVE_VOCABLES_CONFIRMATION_SETTING_NAME ) == strtrue if show_dialog and VocableManager.vocables_changed: save_vocables_confirmation_dialog = SaveVocablesBeforeExitConfirmationDialog(self) save_vocables = save_vocables_confirmation_dialog.run() == Gtk.ResponseType.YES AppSettings.change_setting_by_name(AppSettings.SAVE_VOCABLES_ON_EXIT_SETTING_NAME, save_vocables) save_vocables_confirmation_dialog.destroy() if save_vocables: VocableManager.save_vocables(VocableManager.vocables) exit_on_exit_confirmation = AppSettings.get_setting_by_name(AppSettings.EXIT_ON_EXIT_SETTING_NAME) == strtrue show_exit_confirmation = AppSettings.get_setting_by_name(AppSettings.DIALOG_SHOW_EXIT_CONFIRMATION_SETTING_NAME) if show_exit_confirmation == strtrue: ExitConfirmationDialog.__init__ = timefunction(ExitConfirmationDialog.__init__) # decoration exit_confirmation_dialog = ExitConfirmationDialog(self) exit_confirmation_dialog.run = timefunction(exit_confirmation_dialog.run) # decoration exit_on_exit_confirmation = exit_confirmation_dialog.run() == Gtk.ResponseType.YES AppSettings.change_setting_by_name(AppSettings.EXIT_ON_EXIT_SETTING_NAME, exit_on_exit_confirmation) exit_confirmation_dialog.destroy() if exit_on_exit_confirmation: # print("Clicked YES") AppSettings.save_settings() Gtk.main_quit() sys.exit() else: # print("Clicked NO") pass return GTKSignal.DO_NOT_PROPAGATE
def test_vocable_list_invariance(self): # get vocables vocables = VocableManager.vocables # save vocables VocableManager.save_vocables(vocables) # check if the vocables are still the same VocableManager.load_vocables() new_vocables = VocableManager.vocables # test object inequality, to assure further testing this way is useful assert vocables[0] is not new_vocables[0], \ 'The compared vocable objects are identical.' # for all vocables for index in range(len(vocables)): # for all first language translations for attribute_index in range(len(vocables[index].first_language_translations)): first_language_transaltion_1 = vocables[index].first_language_translations[attribute_index] first_language_transaltion_2 = new_vocables[index].first_language_translations[attribute_index] assert first_language_transaltion_1 == first_language_transaltion_2, \ 'There are differences in a vocable\'s first_language_translations attribute.' # for all first language phonetic scripts for attribute_index in range(len(vocables[index].first_language_phonetic_scripts)): first_language_phonetic_script_1 = vocables[index].first_language_phonetic_scripts[attribute_index] first_language_phonetic_script_2 = new_vocables[index].first_language_phonetic_scripts[attribute_index] assert first_language_phonetic_script_1 == first_language_phonetic_script_2, \ 'There are differences in a vocable\'s first_language_phonetic_scripts attribute.' # for all second language translations for attribute_index in range(len(vocables[index].second_language_translations)): second_language_transaltion_1 = vocables[index].second_language_translations[attribute_index] second_language_transaltion_2 = new_vocables[index].second_language_translations[attribute_index] assert second_language_transaltion_1 == second_language_transaltion_2, \ 'There are differences in a vocable\'s second_language_translations attribute.' # for all second language phonetic scripts for attribute_index in range(len(vocables[index].second_language_phonetic_scripts)): second_language_phonetic_script_1 = vocables[index].second_language_phonetic_scripts[attribute_index] second_language_phonetic_script_2 = new_vocables[index].second_language_phonetic_scripts[attribute_index] assert second_language_phonetic_script_1 == second_language_phonetic_script_2, \ 'There are differences in a vocable\'s second_language_phonetic_scripts attribute.' # for all topics scripts for attribute_index in range(len(vocables[index].topics)): topic_1 = vocables[index].topics[attribute_index] topic_2 = new_vocables[index].topics[attribute_index] assert topic_1 == topic_2, \ 'There are differences in a vocable\'s topics attribute.' # for all chapters scripts for attribute_index in range(len(vocables[index].chapters)): chapter_1 = vocables[index].chapters[attribute_index] chapter_2 = new_vocables[index].chapters[attribute_index] assert chapter_1 == chapter_2, \ 'There are differences in a vocable\'s chapters attribute.' assert vocables[index].learn_level == new_vocables[index].learn_level, \ 'There are differences in a vocable\'s learn_level attribute.' assert vocables[index].relevance_level == new_vocables[index].relevance_level, \ 'There are differences in a vocable\'s relevance_level attribute.' assert vocables[index].description == new_vocables[index].description, \ 'There are differences in a vocable\'s description attribute.'
def test_vocable_list_invariance(self): # get vocables vocables = VocableManager.vocables # save vocables VocableManager.save_vocables(vocables) # check if the vocables are still the same VocableManager.load_vocables() new_vocables = VocableManager.vocables # test object inequality, to assure further testing this way is useful assert vocables[0] is not new_vocables[0], \ 'The compared vocable objects are identical.' # for all vocables for index in range(len(vocables)): # for all first language translations for attribute_index in range( len(vocables[index].first_language_translations)): first_language_transaltion_1 = vocables[ index].first_language_translations[attribute_index] first_language_transaltion_2 = new_vocables[ index].first_language_translations[attribute_index] assert first_language_transaltion_1 == first_language_transaltion_2, \ 'There are differences in a vocable\'s first_language_translations attribute.' # for all first language phonetic scripts for attribute_index in range( len(vocables[index].first_language_phonetic_scripts)): first_language_phonetic_script_1 = vocables[ index].first_language_phonetic_scripts[attribute_index] first_language_phonetic_script_2 = new_vocables[ index].first_language_phonetic_scripts[attribute_index] assert first_language_phonetic_script_1 == first_language_phonetic_script_2, \ 'There are differences in a vocable\'s first_language_phonetic_scripts attribute.' # for all second language translations for attribute_index in range( len(vocables[index].second_language_translations)): second_language_transaltion_1 = vocables[ index].second_language_translations[attribute_index] second_language_transaltion_2 = new_vocables[ index].second_language_translations[attribute_index] assert second_language_transaltion_1 == second_language_transaltion_2, \ 'There are differences in a vocable\'s second_language_translations attribute.' # for all second language phonetic scripts for attribute_index in range( len(vocables[index].second_language_phonetic_scripts)): second_language_phonetic_script_1 = vocables[ index].second_language_phonetic_scripts[attribute_index] second_language_phonetic_script_2 = new_vocables[ index].second_language_phonetic_scripts[attribute_index] assert second_language_phonetic_script_1 == second_language_phonetic_script_2, \ 'There are differences in a vocable\'s second_language_phonetic_scripts attribute.' # for all topics scripts for attribute_index in range(len(vocables[index].topics)): topic_1 = vocables[index].topics[attribute_index] topic_2 = new_vocables[index].topics[attribute_index] assert topic_1 == topic_2, \ 'There are differences in a vocable\'s topics attribute.' # for all chapters scripts for attribute_index in range(len(vocables[index].chapters)): chapter_1 = vocables[index].chapters[attribute_index] chapter_2 = new_vocables[index].chapters[attribute_index] assert chapter_1 == chapter_2, \ 'There are differences in a vocable\'s chapters attribute.' assert vocables[index].learn_level == new_vocables[index].learn_level, \ 'There are differences in a vocable\'s learn_level attribute.' assert vocables[index].relevance_level == new_vocables[index].relevance_level, \ 'There are differences in a vocable\'s relevance_level attribute.' assert vocables[index].description == new_vocables[index].description, \ 'There are differences in a vocable\'s description attribute.'