timApp.tests.server package#

Submodules#

timApp.tests.server.race module#

Server tests for race conditions.

class timApp.tests.server.race.RaceTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_race_bookmark()[source]#

timApp.tests.server.test_access_lock module#

class timApp.tests.server.test_access_lock.AccessLockTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

Tests for access locking and unlocking

tearDown()[source]#

Hook method for deconstructing the test fixture after testing it.

test_access_lock_document_access()[source]#

Test that locking access does not affect document access rules.

test_access_lock_document_redirect()[source]#

Test that document viewing is restricted when access level is locked.

test_access_lock_tasks()[source]#

Test that access locking affects tasks and fields

timApp.tests.server.test_account_delete module#

class timApp.tests.server.test_account_delete.AccountDeleteTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_delete_account()[source]#

timApp.tests.server.test_admin module#

class timApp.tests.server.test_admin.MergeTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_merge_multi()[source]#
test_user_merge()[source]#
class timApp.tests.server.test_admin.SearchTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

class timApp.tests.server.test_admin.UserDeleteTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_deleted_user_logout()[source]#

timApp.tests.server.test_answers module#

class timApp.tests.server.test_answers.AnswerTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

check_totals(user: timApp.user.user.User, task_ids: list[timApp.plugin.taskid.TaskId], task_count, total_points)[source]#
check_user(u: timApp.user.user.User, task_id1: timApp.plugin.taskid.TaskId, task_id2: timApp.plugin.taskid.TaskId)[source]#
test_answer_backup()[source]#
test_answer_disabled()[source]#
test_common_answers()[source]#
test_delete_old_answers()[source]#
test_export_import()[source]#
test_summary()[source]#
test_too_large_answer()[source]#

timApp.tests.server.test_area_behavior module#

class timApp.tests.server.test_area_behavior.AreaTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_area_classed()[source]#
test_area_duplicate_warning()[source]#
test_area_no_wrong_warning()[source]#

If preview has a broken area temporarily, TIM shouldn’t complain about it.

test_name_area()[source]#

timApp.tests.server.test_authors module#

Server tests for showing authors for paragraphs.

class timApp.tests.server.test_authors.AuthorsTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_authors()[source]#

timApp.tests.server.test_autocounters module#

A test for markdownconverter module.

class timApp.tests.server.test_autocounters.AutoCountersTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

check_conversion(html, md, macros=None)[source]#
cnt_labels(labels)[source]#
doc_with_counters(docstr, htmls_ex, msg, setstr=None)[source]#
test_autocounter_by_block_id()[source]#
test_autocounter_by_task_id()[source]#
test_autocounter_by_task_id_no_jump()[source]#
test_autocounter_with_section_numbers()[source]#
test_autotypes()[source]#
test_begin1_environment()[source]#
test_begin_environment()[source]#
test_begin_no_base_name_environment()[source]#
test_fig_counter()[source]#
test_no_c_begin_environment()[source]#
test_no_c_begin_environment_no_man_name()[source]#
test_set_counter_values()[source]#
test_tasks()[source]#

timApp.tests.server.test_bookmarks module#

class timApp.tests.server.test_bookmarks.BookmarkTest(methodName='runTest')[source]#

Bases: timApp.tests.server.test_bookmarks.BookmarkTestBase

test_bookmark_migration_to_db()[source]#
test_bookmarks()[source]#
test_recently_edited()[source]#
class timApp.tests.server.test_bookmarks.BookmarkTest2(methodName='runTest')[source]#

Bases: timApp.tests.server.test_bookmarks.BookmarkTestBase

refresh(i: timApp.document.docinfo.DocInfo)[source]#
test_automatic_course_bookmark_update()[source]#
test_manual_enroll()[source]#
class timApp.tests.server.test_bookmarks.BookmarkTestBase(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

get_bookmarks(expect_status=200)[source]#

timApp.tests.server.test_broken_db module#

class timApp.tests.server.test_broken_db.BrokenDbTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_broken_db()[source]#

timApp.tests.server.test_caching module#

Server tests for document caching.

class timApp.tests.server.test_caching.CachingTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

check_is_cached(d, query=None)[source]#
check_not_cached(d, query=None)[source]#
check_not_cached_and_then_cached(d, query=None)[source]#
get_with_patch(d, query=None)[source]#
test_cache()[source]#
test_cache_generate_exam_mode()[source]#
test_cache_pregenerate()[source]#

timApp.tests.server.test_calendar module#

Server tests for TIM-calendar

class timApp.tests.server.test_calendar.CalendarBookTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

post_event_to_book(event_id)[source]#

Helper function to post a basic event to book

test_booking()[source]#

Event is created by Test user 2 and booked by Test user 1.

class timApp.tests.server.test_calendar.CalendarTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

post_event(event_id: int)[source]#

Helper function to post a basic event

test_event_add_and_delete()[source]#

Events are queried, an event is created by Test user 1 and then deleted

test_event_modification()[source]#

An event is created and then modified by user

timApp.tests.server.test_cbcountfield module#

Server tests for cbcountfield.

class timApp.tests.server.test_cbcountfield.CbCountFieldTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

expect_count(r, count)[source]#
test_cbcountfield()[source]#
test_cbcountfield_grouplogin()[source]#

timApp.tests.server.test_clipboard module#

class timApp.tests.server.test_clipboard.ClipboardTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_copy_area_as_ref()[source]#
test_copy_many()[source]#
test_copy_one()[source]#
test_copy_readings_nonteacher()[source]#
test_copy_to_empty()[source]#
test_cut_to_other_doc()[source]#
test_invalid()[source]#
test_paste_permission()[source]#
test_random_actions()[source]#

timApp.tests.server.test_comments module#

class timApp.tests.server.test_comments.CommentTest(methodName='runTest')[source]#

Bases: timApp.tests.server.test_notify.NotifyTestBase

get_comments(i: timApp.item.item.Item, private=False, deleted=False, expect_status=200)[source]#
post_comment_and_return_html(text: str, par: timApp.document.docparagraph.DocParagraph, public: bool = True) list[lxml.html.HtmlElement][source]#
test_comment_anonymized()[source]#
test_comment_at_area_start()[source]#
test_comment_in_referenced_area()[source]#
test_comment_in_translation()[source]#
test_comment_name_not_visible_when_referenced()[source]#
test_comments()[source]#
test_invalid_comment_delete_request()[source]#
test_invalid_comment_post_request()[source]#
test_nonexistent_note()[source]#
test_nonexistent_note_post()[source]#
test_note_notify()[source]#
test_only_private_comments()[source]#

timApp.tests.server.test_copy_cite module#

class timApp.tests.server.test_copy_cite.CopyCiteTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_cite()[source]#
test_copy()[source]#
test_copy_doc_with_issues()[source]#
test_copy_preamble()[source]#
test_copy_translations()[source]#

Translations of a copied document are also copied.

test_copy_translations_with_default_rights()[source]#

Translations of document are copied and default rights are set correctly.

timApp.tests.server.test_courses module#

class timApp.tests.server.test_courses.CoursesTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_add_course_route()[source]#
test_get_course_settings_doc_not_found()[source]#
test_get_course_settings_find_doc()[source]#
test_get_documents_from_bookmark_folder_folder_found()[source]#
test_get_documents_from_bookmark_folder_folder_not_found()[source]#

timApp.tests.server.test_create_db module#

class timApp.tests.server.test_create_db.CreateDbTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

create_docs = True#
test_initial_docs_exist()[source]#

Initial documents are created.

timApp.tests.server.test_csplugin module#

class timApp.tests.server.test_csplugin.CsPluginTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_csplugin_csharp()[source]#
test_csplugin_pointsrule()[source]#

timApp.tests.server.test_default_rights module#

class timApp.tests.server.test_default_rights.DefaultRightTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_document_default_rights()[source]#
timApp.tests.server.test_default_rights.convert_to_old_format(rights)[source]#

timApp.tests.server.test_dist_rights module#

class timApp.tests.server.test_dist_rights.DistRightsProcessor(dt: datetime.datetime, target_name: str)[source]#

Bases: object

changestarttimegroup(group: str, incr: datetime.timedelta, newtime: datetime.datetime)[source]#
changetime(i: int, incr: datetime.timedelta, secs: int)[source]#
changetimegroup(group: str, incr: datetime.timedelta, secs: int)[source]#
confirm(i: int, incr: datetime.timedelta)[source]#
confirmgroup(group: str, incr: datetime.timedelta)[source]#
dt: datetime.datetime#
quit(i: int, incr: datetime.timedelta)[source]#
target_name: str#
undoconfirm(i: int, incr: datetime.timedelta)[source]#
undoquit(i: int, incr: datetime.timedelta)[source]#
unlock(i: int, incr: datetime.timedelta)[source]#
class timApp.tests.server.test_dist_rights.DistRightsTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

check(base_date, rights, i, rq, d_f, d_t, d_secs, acc_f, acc_t)[source]#
init_processor(target_name: str)[source]#
test_distribute_rights()[source]#
test_distribute_rights_non_duration()[source]#
test_group_manipulation()[source]#
test_receive_rights()[source]#
write_initial(processor: timApp.tests.server.test_dist_rights.DistRightsProcessor, initial_right: timApp.item.distribute_rights.Right, ops: list[Union[timApp.item.distribute_rights.ConfirmOp, timApp.item.distribute_rights.UnlockOp, timApp.item.distribute_rights.ChangeTimeOp, timApp.item.distribute_rights.QuitOp, timApp.item.distribute_rights.UndoConfirmOp, timApp.item.distribute_rights.UndoQuitOp, timApp.item.distribute_rights.ChangeTimeGroupOp, timApp.item.distribute_rights.ChangeStartTimeGroupOp, timApp.item.distribute_rights.ConfirmGroupOp]])[source]#
timApp.tests.server.test_dist_rights.register_right_or_raise(op: Union[timApp.item.distribute_rights.ConfirmOp, timApp.item.distribute_rights.UnlockOp, timApp.item.distribute_rights.ChangeTimeOp, timApp.item.distribute_rights.QuitOp, timApp.item.distribute_rights.UndoConfirmOp, timApp.item.distribute_rights.UndoQuitOp, timApp.item.distribute_rights.ChangeTimeGroupOp, timApp.item.distribute_rights.ChangeStartTimeGroupOp, timApp.item.distribute_rights.ConfirmGroupOp], target_name: str) timApp.item.distribute_rights.RightLog[source]#

timApp.tests.server.test_doc_html module#

class timApp.tests.server.test_doc_html.DocHtmlTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_attrs_visible_attr_no_replace()[source]#

Make sure “visible” attribute is not rendered as boolean (true/false) in HTML after processing.

timApp.tests.server.test_doc_partition module#

class timApp.tests.server.test_doc_partition.DocPartitionTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_b_block_id()[source]#
test_calculating_part_indices()[source]#
test_no_preferred_size()[source]#
test_partitioning_document()[source]#
test_partitioning_document_areas()[source]#
test_partitioning_document_with_overflowing_range()[source]#
test_partitioning_empty_document()[source]#
test_partitioning_with_preambles()[source]#
test_partitioning_with_special_class_preambles()[source]#

timApp.tests.server.test_doc_sass module#

Server tests for xxx.

class timApp.tests.server.test_doc_sass.DocSassTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

get_message(r: lxml.html.HtmlElement)[source]#
test_sass()[source]#

timApp.tests.server.test_doc_settings module#

class timApp.tests.server.test_doc_settings.DocSettingsTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_input_format_change()[source]#
test_invalid_multiline_settings()[source]#
test_invalid_settings()[source]#
test_no_visible_settings_on_save()[source]#
test_settings_merge()[source]#

timApp.tests.server.test_duration module#

class timApp.tests.server.test_duration.DurationTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

get_about_to_access_msg(period='a day')[source]#
get_expired_msg(access)[source]#
test_access_future_and_expired()[source]#
test_duration_group_unlock()[source]#
test_duration_unlock()[source]#
test_duration_value_access_to_clamp()[source]#
test_duration_zero()[source]#
test_timed_duration_unlock()[source]#
test_unlock_needs_confirm()[source]#
unlock_success = 'Item was unlocked successfully.'#

timApp.tests.server.test_editing module#

class timApp.tests.server.test_editing.EditTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_area_editing()[source]#
test_cache_no_extra_div()[source]#
test_download()[source]#
test_download_with_tls()[source]#
test_duplicate_par_ids()[source]#
test_duplicate_task_ids()[source]#
test_duplicate_template()[source]#

Trying to load a template to a non-empty document is not possible.

test_edit_attribute()[source]#
test_get_updates_pars_translation()[source]#
test_getblock()[source]#
test_html_heading_same_as_md()[source]#
test_invalid_add()[source]#
test_invalid_update()[source]#
test_mark_read()[source]#
test_new_from_help_par()[source]#
test_no_area_start_update()[source]#

getUpdatedPars shouldn’t return area start or end pars because it will break the DOM structure.

test_no_unnecessary_update()[source]#
test_no_unnecessary_update_with_preamble()[source]#
test_nonexistent_edit()[source]#
test_nonexistent_template()[source]#

Trying to load a non-existent template gives 404.

test_update()[source]#

Editing a document with minor errors is possible in manage.

Document must not contain any errors after editing.

test_version()[source]#
test_xml_encoding()[source]#
class timApp.tests.server.test_editing.TimTableEditTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_timtable_edit()[source]#

timApp.tests.server.test_feedback_report module#

class timApp.tests.server.test_feedback_report.FeedbackReportTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_data_report()[source]#
test_empty_report()[source]#
test_grant_permission()[source]#
test_missing_fields()[source]#
test_no_permissions()[source]#

timApp.tests.server.test_folders module#

class timApp.tests.server.test_folders.FolderContentTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_folder_content()[source]#
class timApp.tests.server.test_folders.FolderCopyTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_copy_permission()[source]#
test_copy_permission_options()[source]#
test_copy_regression()[source]#
test_copy_to_existing()[source]#
test_default_owner_right()[source]#

Exception when an intermediate folder gets a duplicate owner right because of its default rights.

test_folder_copy()[source]#
test_no_lose_owners_for_templates()[source]#
class timApp.tests.server.test_folders.FolderParentTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_folder_parents()[source]#
test_root_parents()[source]#
class timApp.tests.server.test_folders.FolderTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_folder_delete()[source]#
test_folder_manage()[source]#
test_folder_view_perf()[source]#
test_folders()[source]#
test_intermediate_folders()[source]#

timApp.tests.server.test_graphviz module#

Server tests for graphviz plugin.

class timApp.tests.server.test_graphviz.GraphvizTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_graphviz_nonascii()[source]#

Non-ASCII characters work with graphviz.

timApp.tests.server.test_grouplogin module#

class timApp.tests.server.test_grouplogin.GroupLoginTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_grouplogin()[source]#

timApp.tests.server.test_groups module#

class timApp.tests.server.test_groups.GroupTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

enum_admin_and_groupadmin()[source]#
error_resp(name)[source]#
init_admin()[source]#
init_groupadmin()[source]#
test_doc_group_setting_access()[source]#
test_group_member_sync()[source]#
test_groups()[source]#
test_groups_trim()[source]#
test_invalid_group_setting()[source]#
test_invalid_groups()[source]#
test_nonexistent()[source]#
class timApp.tests.server.test_groups.GroupTest2(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_group_edit_access()[source]#
class timApp.tests.server.test_groups.GroupTest3(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_create_group()[source]#

timApp.tests.server.test_hide_names module#

class timApp.tests.server.test_hide_names.HideNamesTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_no_hide_model_answer_name()[source]#

timApp.tests.server.test_importdata module#

Server tests for importData plugin.

class timApp.tests.server.test_importdata.AaltoImportTest(*args, **kwargs)[source]#

Bases: timApp.tests.server.test_importdata.ImportDataTestBase

test_aalto_import()[source]#
test_import_add_to_group()[source]#
class timApp.tests.server.test_importdata.ImportDataTest(*args, **kwargs)[source]#

Bases: timApp.tests.server.test_importdata.ImportDataTestBase

test_importdata()[source]#
class timApp.tests.server.test_importdata.ImportDataTestBase(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

grant_user_creation_right()[source]#
imp(d, data, expect, status: int, task=None, aalto_return=None)[source]#
timApp.tests.server.test_importdata.field_result(missing_users=None, created_users=None, user_key='username', changed=0, unchanged=0, result_text='', codes=None)[source]#

timApp.tests.server.test_index module#

class timApp.tests.server.test_index.IndexTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

check_doc_preview(d: timApp.document.docinfo.DocInfo)[source]#
test_formatted_heading()[source]#
test_heading_preview()[source]#
test_heading_preview_translation()[source]#
test_heading_preview_translation_nonumber()[source]#
test_index_duplicate_headings()[source]#
test_index_many_headings_per_par()[source]#
test_index_numeric_headings()[source]#
test_index_one_heading_per_par()[source]#
test_index_skip_level()[source]#
test_too_deep_heading()[source]#
test_translation_nonumber_edit()[source]#

timApp.tests.server.test_inlineplugins module#

class timApp.tests.server.test_inlineplugins.InlinePluginTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_inline_plugin_error_html_no_p()[source]#
test_inline_plugin_login()[source]#
test_inline_plugin_no_html_escape()[source]#
test_inline_plugin_ref()[source]#
test_inline_plugin_sanitize()[source]#
test_inline_plugins()[source]#
test_multiline_inlineplugin()[source]#

Multiline markup in inlineplugins works.

timApp.tests.server.test_ip_block module#

Server tests for IP blocking.

class timApp.tests.server.test_ip_block.IpBlockTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_ip_block()[source]#

timApp.tests.server.test_item_create module#

class timApp.tests.server.test_item_create.ItemCreateTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_doc_name_invalid()[source]#
test_folders_invalid()[source]#
test_no_alias_under_doc()[source]#

It’s not possible to create an alias whose path starts with another alias.

test_no_folder_under_translation()[source]#

timApp.tests.server.test_jsrunner module#

Server tests for jsrunner plugin.

class timApp.tests.server.test_jsrunner.JsRunnerGroupTest(methodName='runTest')[source]#

Bases: timApp.tests.server.test_jsrunner.JsRunnerTestBase

test_group_create()[source]#
test_jsrunner_group()[source]#
test_user_filtering()[source]#
class timApp.tests.server.test_jsrunner.JsRunnerTest(methodName='runTest')[source]#

Bases: timApp.tests.server.test_jsrunner.JsRunnerTestBase

create_test_group(ugname: str)[source]#
setUp()[source]#

Hook method for setting up the test fixture before exercising it.

test_add_time_log()[source]#
test_aliases_and_getters()[source]#
test_collaborators()[source]#
test_count_field()[source]#
test_deleted_users()[source]#
test_global_field()[source]#
test_group_wildcard()[source]#
test_infinite_loop()[source]#
test_invalid_aliases()[source]#
test_invalid_field_name()[source]#
test_invalid_markup()[source]#
test_invalid_tally_fields()[source]#
test_mcq_qst_fetch()[source]#
test_mix_tally_and_normal_fields()[source]#
test_multiple_documents()[source]#
test_no_multiple_saves()[source]#
test_no_points_answers_tally()[source]#
test_nonexistent_doc()[source]#
test_points()[source]#
test_print_nonascii()[source]#
test_rights()[source]#
test_runscript()[source]#
test_setters_and_getters()[source]#
test_styles()[source]#
test_syntax_error()[source]#
test_tally_fields()[source]#
class timApp.tests.server.test_jsrunner.JsRunnerTestBase(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

create_group_jsrun(grouplist, group='tg1', method='setGroup')[source]#
create_jsrun(md)[source]#
do_jsrun(d: timApp.document.docinfo.DocInfo, expect_content=None, expect_status=200, user_input=None, runner_name='r', **kwargs)[source]#

timApp.tests.server.test_jyu_account module#

class timApp.tests.server.test_jyu_account.JyuAccountTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_is_jyu_account()[source]#
test_is_not_jyu_account()[source]#

timApp.tests.server.test_late_answers module#

Server tests for xxx.

class timApp.tests.server.test_late_answers.LateAnswersTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_late_answers()[source]#

timApp.tests.server.test_lecture module#

class timApp.tests.server.test_lecture.LectureTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

get_updates(doc_id: int, msg_id: int, use_questions: Optional[bool] = None, curr_q: Optional[int] = None, curr_p: Optional[int] = None, **kwargs)[source]#
test_askedjson()[source]#
test_empty_lectureanswer()[source]#
test_invalid_max_students()[source]#
test_lecture()[source]#
test_no_multiple_lectures()[source]#

User won’t join to multiple lectures if he creates many of them.

test_shuffled_questions()[source]#

timApp.tests.server.test_macros module#

Server tests for macros.

class timApp.tests.server.test_macros.MacroTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_addforevery_only_settings()[source]#
test_doc_macros()[source]#
test_globalmacros_with_reference()[source]#
test_host_macros()[source]#
test_invalid_macros()[source]#
test_macro_doc()[source]#
test_macro_only_delimiter()[source]#
test_null_macros()[source]#
test_user_macros()[source]#
test_user_nocache()[source]#
test_usermacro_in_plugin()[source]#

User-specific macros in plugins.

test_usermacros_no_xss()[source]#

timApp.tests.server.test_manage module#

class timApp.tests.server.test_manage.ManageTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_alias_no_empty_path_part()[source]#
test_document_delete()[source]#
test_item_rights()[source]#
test_manage()[source]#
test_shortname_public_toggle()[source]#

timApp.tests.server.test_math module#

class timApp.tests.server.test_math.MathTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_math_plugin()[source]#
test_math_preamble()[source]#
test_math_preamble_single_par()[source]#
test_mathjax_math()[source]#
test_mathtype_change()[source]#
test_mixed_settings()[source]#
test_svg_math()[source]#

timApp.tests.server.test_messagelist module#

class timApp.tests.server.test_messagelist.JSRunnerMessageListTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimMessageListTest, timApp.tests.server.test_jsrunner.JsRunnerTestBase

test_jsrunner_mail_sync()[source]#

Test JSRunner group actions sync with mailman

class timApp.tests.server.test_messagelist.MessageListTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimMessageListTest

Server test for message lists.

test_creation_valid_name()[source]#

Test creating a message list with a valid user and valid list name.

test_mail_archive_access()[source]#
test_mail_archiving_processing()[source]#
test_mailman_members()[source]#
test_primary_email_sync()[source]#

Test primary email sync with Mailman

test_scim_mail_sync()[source]#

timApp.tests.server.test_minutes module#

class timApp.tests.server.test_minutes.MinutesCreation(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_minutes_creation()[source]#
class timApp.tests.server.test_minutes.MinutesHandling(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

test_minute_extracts()[source]#

timApp.tests.server.test_notify module#

class timApp.tests.server.test_notify.AnswerNotifyTest(methodName='runTest')[source]#

Bases: timApp.tests.server.test_notify.NotifyTestBase

test_answer_notify()[source]#

Test that the notification is sent when a user sends an answer to a question.

class timApp.tests.server.test_notify.CutPasteNotifyTest(methodName='runTest')[source]#

Bases: timApp.tests.server.test_notify.NotifyTestBase

test_cut_paste()[source]#
class timApp.tests.server.test_notify.NotifyFolderTest(methodName='runTest')[source]#

Bases: timApp.tests.server.test_notify.NotifyTestBase

test_folder_email()[source]#
class timApp.tests.server.test_notify.NotifyTest(methodName='runTest')[source]#

Bases: timApp.tests.server.test_notify.NotifyTestBase

test_notify()[source]#
test_notify_email()[source]#
test_revoke_view_no_email()[source]#
class timApp.tests.server.test_notify.NotifyTestBase(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

prepare_doc(add_new_par=True) tuple[timApp.document.docinfo.DocInfo, str, str][source]#
setUp()[source]#

Hook method for setting up the test fixture before exercising it.

update_notify_settings(d, new_settings)[source]#

timApp.tests.server.test_oauth2 module#

class timApp.tests.server.test_oauth2.OAuth2Test(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_oauth2_login()[source]#

timApp.tests.server.test_par_diff module#

Server tests for getParDiff route.

class timApp.tests.server.test_par_diff.ParDiffTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_diff_normal_to_reference()[source]#
test_par_diff()[source]#
test_reference_par()[source]#

No exception is thrown when a reference par is in the “equal” section of the diff result.

timApp.tests.server.test_par_visibility module#

Server tests for user/view-specific document rendering.

class timApp.tests.server.test_par_visibility.ParVisibilityTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_area_visible()[source]#
test_belongs()[source]#
test_belongs_in_text()[source]#
test_isview()[source]#

timApp.tests.server.test_password_hashing module#

Tests for password hashing.

class timApp.tests.server.test_password_hashing.PasswordTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_bcrypt_hash()[source]#
test_hash_migration()[source]#

timApp.tests.server.test_peer_review module#

Server tests for peer review.

class timApp.tests.server.test_peer_review.PeerReviewTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_peer_review_generate()[source]#

timApp.tests.server.test_permissions module#

class timApp.tests.server.test_permissions.PermissionTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_access_denied_message()[source]#
test_auto_confirm_translation()[source]#
test_cannot_auto_confirm_too_early()[source]#
test_cannot_change_owner_of_personal_folder()[source]#
test_cannot_remove_ownership()[source]#
test_chaining()[source]#
test_chaining_logged_in()[source]#
test_confirm_with_end_date()[source]#
test_duration_right()[source]#
test_inherit_rights_from_folder()[source]#
test_logged_in_right()[source]#
test_mass_permission_remove_partially_redundant()[source]#

Rights are removed even if the selection contains redundant rows.

test_no_fulltext_in_manage_with_view()[source]#
test_non_owner_cannot_change_owner()[source]#
test_nonexistent_user()[source]#
test_permission_clear()[source]#
test_permissions_get()[source]#
test_recursive_permissions()[source]#
test_self_expire()[source]#
test_trim_whitespace()[source]#

timApp.tests.server.test_plugins module#

class timApp.tests.server.test_plugins.PluginTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

answer_error = {'error': "You don't have access to this answer."}#
check_failed_answer(resp, is_new=False)[source]#
check_ok_answer(resp, is_new=True)[source]#
check_save_points(user_id, answer_id, points, expect_status, expect_content)[source]#
do_plugin_upload(d: timApp.document.docinfo.DocInfo, file_content, filename, task_id, task_name, expect_version=1)[source]#
exclude_answered_on_id(answer_list)[source]#
test_all_answers()[source]#
test_answer_rename()[source]#
test_broken_upload()[source]#

Ensures accessing an unassociated upload won’t throw an exception.

test_cache_no_browser()[source]#
test_deadline_datetime()[source]#
test_find_tasks()[source]#
test_group_answering()[source]#
test_hide_names()[source]#
test_idless_plugin()[source]#
test_interval()[source]#
test_invalid_getstate()[source]#
test_invalid_global_attrs()[source]#
test_invalid_interval()[source]#
test_invalid_taskid()[source]#
test_invalid_yaml()[source]#
test_lazyonly_browser()[source]#
test_no_need_browser()[source]#
test_nonexistent_plugin()[source]#
test_pali()[source]#
test_plugin()[source]#
test_plugin_empty_markup()[source]#
test_plugin_refcopy_contentcopy()[source]#

Tests a rare case outlined in #1902 where a plugin is copied first by reference and then by content.

test_plugin_run_user_macro()[source]#
test_plugin_user_modifiers()[source]#

Save and show answers according to global field and useCurrentUser logic

test_point_sum_rule()[source]#
test_pointsrule_floats()[source]#
test_pointsrule_invalid()[source]#
test_pointsrule_plugin_specific()[source]#
test_rbfield_no_redundant_save()[source]#
test_readonly_specifier()[source]#
test_save_points()[source]#
test_save_teachers_fix()[source]#
test_taskid_field()[source]#
test_taskid_reference()[source]#
test_taskid_reference_teacher()[source]#
test_timtable_nonexistent_route()[source]#

Calling non-existent timTable route won’t result in an infinite request loop.

test_translation_plugin_state()[source]#

Plugin’s initial state is correctly loaded in a translated document.

test_upload()[source]#

timApp.tests.server.test_plugins_preamble module#

class timApp.tests.server.test_plugins_preamble.PluginPreambleTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

check_plugin_ref_correct(doc_to_check: timApp.document.docinfo.DocInfo, expected_doc: timApp.document.docinfo.DocInfo, expected_par: timApp.document.docparagraph.DocParagraph, text_to_check='', preamble_doc: Optional[timApp.document.docinfo.DocInfo] = None)[source]#
run_plugin_in_preamble(doc_path: str, create_preamble_translation=True)[source]#
run_referenced_plugin_in_preamble(doc_path: str, create_preamble_translation=True)[source]#
test_plugin_in_preamble()[source]#
test_reference_to_preamble()[source]#
test_referenced_plugin_in_preamble()[source]#

timApp.tests.server.test_preamble module#

Server tests for preamble.

class timApp.tests.server.test_preamble.PreambleTest(methodName='runTest')[source]#

Bases: timApp.tests.server.test_preamble.PreambleTestBase

test_preamble_content()[source]#
test_preamble_perf()[source]#
test_preamble_self()[source]#
test_preamble_settings()[source]#
class timApp.tests.server.test_preamble.PreambleTest2(methodName='runTest')[source]#

Bases: timApp.tests.server.test_preamble.PreambleTestBase

test_preamble_area_settings()[source]#
test_preamble_heading_numbering()[source]#
test_preamble_unique_ids()[source]#
class timApp.tests.server.test_preamble.PreambleTest3(methodName='runTest')[source]#

Bases: timApp.tests.server.test_preamble.PreambleTestBase

test_multiple_preamble()[source]#
test_preamble_ref()[source]#
test_preamble_translation()[source]#
class timApp.tests.server.test_preamble.PreambleTest4(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_absolute_preamble()[source]#

User may refer to preambles located in an absolute path

test_absolute_preamble_order()[source]#

Preambles located in an absolute path will be treated last

test_preambles_self_reference()[source]#

Preamble shall not refer to itself

class timApp.tests.server.test_preamble.PreambleTestBase(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

create_doc_and_preamble(folder: str)[source]#
create_preambles(folder: str, preamble_name: str)[source]#

timApp.tests.server.test_preview module#

Server tests for preview.

class timApp.tests.server.test_preview.PreviewTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

check_spelling(d, expected, markdown)[source]#
test_attributes_at_end_of_code_block()[source]#
test_help_par()[source]#
test_line_break()[source]#
test_preamble_preview_first()[source]#

Make sure an exception won’t occur when editing the first paragraph of a document with a preamble.

test_preview_permission()[source]#
test_spellcheck()[source]#
test_translation_invalid_ref()[source]#

timApp.tests.server.test_printing module#

Server tests for printing.

class timApp.tests.server.test_printing.PrintingTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

create_docs = True#
create_empty_print_template()[source]#
test_print_invalid_request()[source]#
test_print_latex_autonumber()[source]#
test_print_latex_pdf()[source]#
class timApp.tests.server.test_printing.SubtitlesTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_print_video_subtitles_chunks()[source]#
test_print_video_subtitles_document()[source]#

timApp.tests.server.test_question module#

class timApp.tests.server.test_question.QuestionTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

test_hidden_points()[source]#
test_question_answer_markdown_html()[source]#
test_question_default_points()[source]#
test_question_html()[source]#
test_question_invalid_numeric_keys()[source]#
test_question_shuffle()[source]#

make shuffled qst, answer with user2, remove shuffle, answer with user3, answer again with user2 user2 points should be based on original shuffle even after shuffle removal user3 points should be based on non-shuffled rows

timApp.tests.server.test_quicklogin module#

class timApp.tests.server.test_quicklogin.QuickLoginTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_quicklogin()[source]#
test_quicklogin_model_answer()[source]#

timApp.tests.server.test_random module#

Server tests for randomization.

class timApp.tests.server.test_random.RandomTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

get_number_list(d, index=0)[source]#
test_doc_rnds()[source]#
test_rnd_s()[source]#

timApp.tests.server.test_readings module#

class timApp.tests.server.test_readings.ReadingsTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

check_readlines(readlines, expected)[source]#
get_readings(doc: timApp.document.docinfo.DocInfo)[source]#
test_expiry()[source]#
test_expiry_invalid()[source]#
test_mark_all_read()[source]#
test_mark_all_read_par_id_conflict()[source]#
Situation:
  • 2 documents

  • both have 2 paragraphs with same ids

  • one of the documents has a ref paragraph to the other

  • make sure “mark all read” works for both

test_preamble_read()[source]#
test_readings_group()[source]#
test_readings_json()[source]#
test_readings_normal()[source]#
test_same_par_id_diff_doc_reference()[source]#
test_tr_separate_readings()[source]#
test_unread_nonexistent()[source]#

timApp.tests.server.test_referencing module#

class timApp.tests.server.test_referencing.ReferencingTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_cyclic_area_reference()[source]#
test_cyclic_reference()[source]#
test_invalid_reference_translation()[source]#
test_reference()[source]#
test_reference_self()[source]#
test_visible_attribute_reference()[source]#

timApp.tests.server.test_relevance module#

class timApp.tests.server.test_relevance.RelevanceTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_get_relevance_default()[source]#
test_get_relevance_inherited()[source]#
test_set_and_replace_relevance_and_get()[source]#
test_set_relevance_and_get()[source]#
test_set_relevance_no_manage_rights()[source]#

timApp.tests.server.test_replace module#

class timApp.tests.server.test_replace.ReplaceTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_header_fix()[source]#
test_replace()[source]#
test_replace_no_regex()[source]#
test_skip_invalid_yaml()[source]#

timApp.tests.server.test_sanitize module#

Server tests for verifying the absence of XSS or other DOM sanitization issues in certain scenarios.

class timApp.tests.server.test_sanitize.SanitizeTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_html_tag_sanitize()[source]#
test_nocache_xss()[source]#

timApp.tests.server.test_scheduled_functions module#

class timApp.tests.server.test_scheduled_functions.ScheduledFunctionRunTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

no_request_context()[source]#
test_import_function_with_create_users()[source]#
test_scheduled_function()[source]#
test_scheduled_function_chain()[source]#
test_scheduled_function_exportdata()[source]#
class timApp.tests.server.test_scheduled_functions.ScheduledFunctionTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_function_listing()[source]#
test_scheduled_function()[source]#

timApp.tests.server.test_scim module#

class timApp.tests.server.test_scim.ScimTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

check_no_group_access(username: str, externalids: list[str], no_access_expected=None)[source]#
check_potential_groups(uname: str, expected)[source]#
test_duplicate_email()[source]#
test_duplicate_usernames()[source]#
test_email_resolution()[source]#
test_inconsistent_name()[source]#
test_ip_access()[source]#
test_no_display_in_members()[source]#
test_potential_groups()[source]#
test_same_display_name()[source]#
test_schema_and_id_in_groups_put()[source]#
test_scim()[source]#
test_scim_auto_user_merge()[source]#
test_scim_group_manual_member_update()[source]#
test_scim_overlapping_displaynames()[source]#
test_scim_permission_update_on_new_teachers_group()[source]#

Make sure the rights of already activated groups are updated if the teachers group is provisioned later.

test_uuid_externalid()[source]#
class timApp.tests.server.test_scim.SendGradeTest(methodName='runTest')[source]#

Bases: timApp.tests.server.test_scim.SendGradeTestBase

test_send_grades()[source]#
class timApp.tests.server.test_scim.SendGradeTestBase(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

check_send_grade_result(grade_params: dict[str, Any], expect_content: dict[str, Any], mock_sisu_response: dict[str, Any] | None, mock_sisu_status=200, expect_status=200)[source]#
class timApp.tests.server.test_scim.StrCreditTest(methodName='runTest')[source]#

Bases: timApp.tests.server.test_scim.SendGradeTestBase

test_str_credit()[source]#
timApp.tests.server.test_scim.add_name_parts(datas)[source]#
timApp.tests.server.test_scim.scim_error(msg: str, code=422)[source]#

timApp.tests.server.test_scoreboard module#

Server tests for scoreboard.

class timApp.tests.server.test_scoreboard.ScoreboardTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_scoreboard()[source]#

timApp.tests.server.test_settings module#

class timApp.tests.server.test_settings.SettingsTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_info()[source]#
test_info_no_points()[source]#
test_settings_get_single()[source]#
test_settings_no_xss()[source]#
test_settings_save()[source]#

timApp.tests.server.test_showfile module#

class timApp.tests.server.test_showfile.ShowfileTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

test_no_local_file_access()[source]#

timApp.tests.server.test_signup module#

class timApp.tests.server.test_signup.OneLoginMock(info: timApp.user.user.UserInfo, assurance_levels: list[str], mock_missing_uniquecode: bool = False)[source]#

Bases: object

assurance_levels: list[str]#
get_attribute(name)[source]#
get_errors()[source]#
get_settings()[source]#
info: timApp.user.user.UserInfo#
is_authenticated()[source]#
mock_missing_uniquecode: bool = False#
process_response(request_id)[source]#
class timApp.tests.server.test_signup.SettingsMock[source]#

Bases: object

get_sp_data()[source]#
class timApp.tests.server.test_signup.TestSignUp(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

create_or_update_test_user(username='johmadoe', real_name='Doe John Matt', email='john.m.doe@student.jyu.fi')[source]#
do_acs_mock(info: timApp.user.user.UserInfo, missing_uniquecode=False, assurance_levels=None)[source]#
setUp()[source]#

Hook method for setting up the test fixture before exercising it.

test_block_bot_signup()[source]#
test_email_login_with_korppi_username()[source]#
test_email_login_without_pass()[source]#
test_email_user_to_korppi()[source]#

When an email user logs in with Korppi, no new account is created but the current account information is updated.

test_haka_invalid_settings()[source]#
test_haka_login()[source]#
test_haka_login_email_conflict()[source]#
test_invalid_email()[source]#
test_korppi_email_signup()[source]#

A Korppi user can update their password (and real name) by signing up.

test_korppi_info_change()[source]#

TIM can handle cases where some information about the user changes in Korppi.

test_korppi_signup()[source]#

Korppi signup succeeds.

test_korppi_user_reset_pass_with_username()[source]#

A Korppi user can reset their password using their username.

test_login_case_insensitive()[source]#
test_login_fail()[source]#
test_missing_uniquecode()[source]#
test_no_password_reset()[source]#
test_password_mismatch()[source]#
test_signup()[source]#
test_signup_case_insensitive()[source]#
test_signup_whitespace()[source]#
test_simple_login()[source]#
test_student_id_login_match()[source]#
test_temp_password_wrong()[source]#
test_too_short_password()[source]#

timApp.tests.server.test_slide module#

class timApp.tests.server.test_slide.SlideTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

check_slide_content(d)[source]#
test_slide_html()[source]#

timApp.tests.server.test_tableform module#

class timApp.tests.server.test_tableform.TableFormTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_answered_users_group()[source]#

timApp.tests.server.test_tags module#

class timApp.tests.server.test_tags.TagTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_adding_duplicate_tag()[source]#
test_get_all_tags()[source]#
test_get_docs_by_tag()[source]#
test_get_document_by_id()[source]#
test_special_tag_adding_with_admin_rights()[source]#
test_special_tag_adding_with_teachers_rights()[source]#
test_special_tag_adding_without_rights()[source]#
test_special_tag_removal_with_teachers_rights()[source]#
test_special_tag_removal_without_rights()[source]#
test_tag_adding_with_manage()[source]#
test_tag_adding_with_special_chars()[source]#
test_tag_adding_without_manage()[source]#
test_tag_edit()[source]#
test_tag_removal_with_manage()[source]#
test_tag_removal_without_manage()[source]#

timApp.tests.server.test_teacher module#

Server tests for xxx.

class timApp.tests.server.test_teacher.TeacherTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_teacher()[source]#
test_teacher_nonexistent_group()[source]#
test_teacher_single_user_in_group()[source]#

timApp.tests.server.test_templates module#

class timApp.tests.server.test_templates.TemplateTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_automatic_template()[source]#
test_templates()[source]#
test_templates_of_templates()[source]#

Templates are not templates of themselves.

timApp.tests.server.test_themes module#

class timApp.tests.server.test_themes.DocThemesTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_theme_overrides()[source]#
timApp.tests.server.test_themes.get_theme_style_name(html: lxml.html.HtmlElement, style_origin: str) str | None[source]#

timApp.tests.server.test_tim module#

Unit tests for TIM routes.

class timApp.tests.server.test_tim.TimTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_activities()[source]#
test_answers_no_crash()[source]#

Don’t crash if anonymous user opens answers view.

test_broken_comment()[source]#
test_clear_cache()[source]#
test_csrf()[source]#
test_document_intermediate_folders()[source]#
test_getproxy()[source]#
test_hide_top_buttons()[source]#
test_no_db_for_js()[source]#

Database is not accessed during a JS file request.

test_par_info()[source]#
test_ping()[source]#
test_same_heading_as_par()[source]#
test_windows_eol()[source]#

Windows-style EOLs should work with Dumbo.

timApp.tests.server.test_tim_message module#

class timApp.tests.server.test_tim_message.SendMessageTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_send_message()[source]#
class timApp.tests.server.test_tim_message.UrlTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_url_check()[source]#

timApp.tests.server.test_translation module#

timApp.tests.server.test_translation.MAX_TEST_CHAR_QUOTA = 50#

Amount of characters to initialize the quota-limited test translator with.

class timApp.tests.server.test_translation.QuotaLimitedTestTranslator(**kwargs)[source]#

Bases: timApp.document.translation.reversingtranslator.ReversingTranslationService

A test translator that can run out of quota mid-translation. Used for simulating a translation service, that returns an error when translation-quota is exceeded by the caller (such as the case with DeepL Free).

character_limit#

Amount of characters allowed to translate.

id#

Translation service identifier.

service_name#

Human-readable name of the machine translator. Also used as an identifier.

translate(texts: list[list[timApp.document.translation.translationparser.TranslateApproval]], source_lang: timApp.document.translation.language.Language, target_lang: timApp.document.translation.language.Language, *, tag_handling: str = '') list[str][source]#

Reverse the translatable text given. NOTE The algorithm here for combining translation results back to original structure might be integrated into the actual TranslationService-implementation. Note This implementation does not fully follow the needed interface.

Returns

Parameters
  • texts – Texts to reverse

  • src_lang – Any.

  • target_lang – Only REVERSE_LANG[“lang_code”] is supported.

  • tag_handling – tags to intelligently handle during translation TODO XML-handling.

Returns

Texts where translatable ones have been reversed.

usage() timApp.document.translation.translator.Usage[source]#

Infinite quota

class timApp.tests.server.test_translation.TimTranslationTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

Test class containing the reversing translation service and its preferred target language.

classmethod setUpClass()[source]#

Hook method for setting up class fixture before running tests in the class.

class timApp.tests.server.test_translation.TranslationTest(methodName='runTest')[source]#

Bases: timApp.tests.server.test_translation.TimTranslationTest

assert_translation_synced(tr_doc: timApp.document.document.Document, doc: timApp.document.docinfo.DocInfo)[source]#
check_outofdate_count(t, count)[source]#
check_preview_diff(t, tr_par, old, new)[source]#
test_document_machine_translation_route()[source]#
test_document_machine_translation_route_forbidden()[source]#
test_document_machine_translation_route_no_api_key()[source]#
test_invalid_language()[source]#
test_mark_all_translated()[source]#
test_paragraph_machine_translation_route()[source]#
test_paragraph_machine_translation_route_forbidden()[source]#
test_paragraph_machine_translation_route_no_api_key()[source]#
test_paragraph_machine_translation_route_plugin()[source]#
test_quota_exceeded_error()[source]#

Test the case where quota runs out during translation.

test_text_machine_translation_route()[source]#
test_text_machine_translation_route_forbidden()[source]#
test_text_machine_translation_route_no_api_key()[source]#
test_translation_alias_delete()[source]#
test_translation_content()[source]#
test_translation_create()[source]#
test_translation_create_with_settings()[source]#
test_translation_delete()[source]#
test_translation_extraneous_pars()[source]#

Any extraneous blocks (those without “rp” attribute) in translation documents are retained after syncing.

test_translation_ignored_src_doc()[source]#
test_translation_invalid()[source]#

Missing rp attribute will not crash the document.

test_translation_outofdate()[source]#
test_translation_perf()[source]#
test_translation_settings()[source]#
test_translation_sync()[source]#

Translations are kept in sync.

timApp.tests.server.test_upload module#

class timApp.tests.server.test_upload.UploadTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

check_mime(f, expected)[source]#
create_doc_with_image()[source]#
test_upload_and_paste_to_other()[source]#
test_upload_and_stamp()[source]#
test_upload_copy_doc()[source]#
test_upload_file()[source]#
test_upload_image()[source]#
test_upload_mimetype()[source]#
test_upload_permissions()[source]#

timApp.tests.server.test_url_redirect module#

class timApp.tests.server.test_url_redirect.RedirectTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_redirect()[source]#
test_slash_redirect()[source]#

timApp.tests.server.test_user_sessions module#

class timApp.tests.server.test_user_sessions.UserSessionsTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

assert_sesion_expired_state(session_ids: list[str], state: list[bool], msg: str) None[source]#

Assert the state of Test User 1’s sessions.

forget_session()[source]#

Forget the current session. Simulates user e.g. closing an incognito window.

latest_session() timApp.auth.session.model.UserSession[source]#

Get latest session of Test User 1.

test_session_access_block()[source]#

Test that expired sessions cannot access documents.

test_session_basic()[source]#

Test that sessions are tracked when SESSIONS_ENABLE is True.

test_session_invalidate() None[source]#
test_session_validity()[source]#

Test cases where the session can invalidate itself.

test_session_verify_remote()[source]#

Test that a session can be verified remotely.

timApp.tests.server.test_velp module#

Tested routes from velp.py:

/<int:doc_id>/get_default_velp_group /<int:doc_id>/get_velps /<int:doc_id>/get_velp_groups /<int:doc_id>/get_velp_labels /add_velp /<int:doc_id>/update_velp /add_velp_label /update_velp_label /<int:doc_id>/create_velp_group /<int:doc_id>/create_default_velp_group

class timApp.tests.server.test_velp.VelpAnonymizationTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_annotation_anonymization()[source]#
class timApp.tests.server.test_velp.VelpTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

test_nonexistent_group()[source]#
test_velp()[source]#

timApp.tests.server.test_verification module#

class timApp.tests.server.test_verification.VerificationTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

Test user verification

test_add_email_contacts()[source]#

Test adding email

test_custom_verify_template()[source]#

Test custom verify templates

timApp.tests.server.timroutetest module#

Defines the TimRouteTest class.

class timApp.tests.server.timroutetest.TimMessageListTest(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

MessageEventType#

alias of Union[timApp.messaging.messagelist.mailman_events.NewMessageEvent, timApp.messaging.messagelist.mailman_events.SubscriptionEvent]

add_list_member(list_name: str, candidates: list[str]) None[source]#
create_list(name: str, archive: timApp.messaging.messagelist.listinfo.ArchiveType) tuple[dict[str, Any], timApp.messaging.messagelist.messagelist_models.MessageListModel][source]#
classmethod setUpClass()[source]#

Hook method for setting up class fixture before running tests in the class.

trigger_mailman_event(event: Union[timApp.messaging.messagelist.mailman_events.NewMessageEvent, timApp.messaging.messagelist.mailman_events.SubscriptionEvent]) None[source]#
trigger_message_send(message_list: timApp.messaging.messagelist.messagelist_models.MessageListModel, user: timApp.user.user.User, subject: Optional[str] = None, body: Optional[str] = None)[source]#
class timApp.tests.server.timroutetest.TimPluginFix(methodName='runTest')[source]#

Bases: timApp.tests.server.timroutetest.TimRouteTest

Unused class. This was a test whether local plugins could be made to work without BrowserTest class.

setUp()[source]#

Hook method for setting up the test fixture before exercising it.

tearDown()[source]#

Hook method for deconstructing the test fixture after testing it.

class timApp.tests.server.timroutetest.TimRouteTest(methodName='runTest')[source]#

Bases: timApp.tests.db.timdbtest.TimDbTest

A base class for running tests for TIM routes.

add_answer(d: timApp.document.docinfo.DocInfo, task_name: str, content: Any = '', points: Union[None, int, float] = None, valid: bool = True, content_key: str | None = 'c', user: Optional[timApp.user.user.User] = None, last_points_modifier: Optional[int] = None)[source]#
classmethod add_language(lang_name: str) timApp.document.translation.language.Language[source]#

Add a Language to the database.

Parameters

lang_name – Name of the language that langcodes could recognize.

Returns

The newly added Language.

assert_content(element: lxml.html.HtmlElement, expected: list[str])[source]#
assert_elements_equal(e1, e2)[source]#
assert_js_variable(element: lxml.html.HtmlElement, variable_name: str, expect_content: Any)[source]#

Check a JavaScript variable from view_html.jinja2.

Parameters
  • element – HTML-tree.

  • variable_name – Variable name as it’s in the <script>.

  • expect_content – Expected content.

Returns

None; raises error if variable was not found or content didn’t match.

assert_plugin_json(e: lxml.html.HtmlElement, content: dict[str, Any])[source]#
assert_same_html(elem, expected_html: str)[source]#
check_contains(expect_contains, data)[source]#
copy(doc: timApp.document.docinfo.DocInfo, par_start: timApp.document.docparagraph.DocParagraph, par_end: timApp.document.docparagraph.DocParagraph, area_name: Optional[str] = None, **kwargs)[source]#
create_doc(path: Optional[str] = None, from_file: Optional[str] = None, initial_par: Optional[Union[str, list[str]]] = None, settings: Optional[dict] = None, copy_from: Optional[int] = None, cite: Optional[int] = None, template: Optional[str] = None, title: Optional[str] = None, expect_status=200, **kwargs) timApp.document.docentry.DocEntry | None[source]#

Creates a new document.

Parameters
  • copy_from – The id of an existing document if creating a copy.

  • cite – The id of an existing document if citing another document.

  • path – The path of the document.

  • from_file – If specified, loads the document content from the specified file.

  • initial_par – The content of the initial paragraph.

  • settings – The settings for the document.

Returns

The DocEntry object.

create_folder(path: str, title: str = 'foldertitle', expect_status=200, **kwargs)[source]#
create_plugin_json(d: timApp.document.docinfo.DocInfo, task_name: str, par_id: Optional[str] = None, markup=None, state=None, toplevel=None, info=None)[source]#
create_preamble_for(d: timApp.item.item.Item, preamble_name: str = 'preamble', **kwargs) timApp.document.docentry.DocEntry | None[source]#
create_translation(doc: timApp.document.docentry.DocEntry, doc_title: str = 'title', lang: str = 'en', expect_contains=None, expect_content=None, expect_status=200, **kwargs) timApp.document.translation.translation.Translation | None[source]#
current_group() timApp.user.usergroup.UserGroup[source]#
property current_user: timApp.user.user.User | None#
static current_user_id() int | None[source]#

Returns the name of the current user.

Returns

The name of the current user.

cut(doc: timApp.document.docinfo.DocInfo, par_start: timApp.document.docparagraph.DocParagraph, par_end: timApp.document.docparagraph.DocParagraph, **kwargs)[source]#
delete(url: str, as_tree: bool = False, expect_status: int | None = 200, expect_content: Union[None, str, dict, list] = None, expect_contains: Optional[Union[str, list[str]]] = None, expect_xpath: Optional[str] = None, json_key: Optional[str] = None, headers: Optional[list[tuple[str, str]]] = None, **kwargs)[source]#

Performs a DELETE request.

See the ‘request’ method for parameter explanations.

delete_area(doc: timApp.document.docinfo.DocInfo, area_start: str, area_end: str, **kwargs)[source]#
delete_par(doc: timApp.document.docinfo.DocInfo, par_id: str, **kwargs)[source]#
doc_num = 1#
edit_comment(note_id, par, public, text, **kwargs)[source]#
get(url: str, as_tree: bool = False, expect_status: int | None = 200, expect_content: Union[None, str, dict, list] = None, expect_contains: Union[None, str, list[str], dict] = None, expect_xpath: Optional[str] = None, expect_cookie: Optional[tuple[str, str | None]] = None, json_key: Optional[str] = None, headers: Optional[list[tuple[str, str]]] = None, auth: Optional[tuple[str, str]] = None, **kwargs)[source]#

Performs a GET request.

See the ‘request’ method for parameter explanations.

get_js_variable(element, variable_name)[source]#
get_no_warn(url: str, **kwargs)[source]#
get_personal_item_path(path)[source]#
get_plugin_json(e: lxml.html.HtmlElement)[source]#
get_state(aid: int, **kwargs)[source]#
get_task_answers(task_id, user: Optional[timApp.user.user.User] = None)[source]#
get_updated_pars(d: timApp.document.docinfo.DocInfo, **kwargs)[source]#
importdata_ctx(aalto_return=None)[source]#
internal_container_ctx()[source]#
Redirects internal container requests to go through Flask test client.

Otherwise such requests would fail during test, unless BrowserTest class is used.

TODO: Using BrowserTest in cases where it’s not actually a browser test should be fixed to

use this method instead.

property is_logged_in#
json_delete(url: str, json_data: Optional[dict] = None, as_tree: bool = False, expect_status: int | None = 200, expect_content: Union[None, str, dict, list] = None, expect_contains: Optional[Union[str, list[str]]] = None, expect_xpath: Optional[str] = None, json_key: Optional[str] = None, headers: Optional[list[tuple[str, str]]] = None, auth: Optional[tuple[str, str]] = None, **kwargs)[source]#

Performs a JSON DELETE request.

Parameters
  • url – The request URL.

  • json_data – The JSON data to be submitted.

  • kwargs – Any custom parameters that are accepted by the ‘request’ method.

Returns

See the ‘request’ method.

json_post(url: str, json_data: Optional[Union[dict, list]] = None, as_tree: bool = False, expect_status: int | None = 200, expect_content: Union[None, str, dict, list] = None, expect_contains: Union[None, str, list[str], dict] = None, expect_xpath: Optional[str] = None, expect_cookie: Optional[tuple[str, str | None]] = None, json_key: Optional[str] = None, headers: Optional[list[tuple[str, str]]] = None, auth: Optional[tuple[str, str]] = None, **kwargs)[source]#

Performs a JSON POST request.

Parameters
  • url – The request URL.

  • json_data – The JSON data to be submitted.

  • kwargs – Any custom parameters that are accepted by the ‘request’ method.

Returns

See the ‘request’ method.

json_put(url: str, json_data: Optional[dict] = None, as_tree: bool = False, expect_status: int | None = 200, expect_content: Union[None, str, dict, list] = None, expect_contains: Optional[Union[str, list[str]]] = None, expect_xpath: Optional[str] = None, json_key: Optional[str] = None, headers: Optional[list[tuple[str, str]]] = None, **kwargs)[source]#

Performs a JSON PUT request.

Parameters
  • url – The request URL.

  • json_data – The JSON data to be submitted.

  • kwargs – Any custom parameters that are accepted by the ‘request’ method.

Returns

See the ‘request’ method.

json_req(url: str, json_data: Optional[dict] = None, method: str = 'GET', as_tree: bool = False, expect_status: int | None = 200, expect_content: Union[None, str, dict, list] = None, expect_contains: Optional[Union[str, list[str]]] = None, expect_xpath: Optional[str] = None, expect_cookie: Optional[tuple[str, str | None]] = None, json_key: Optional[str] = None, headers: Optional[list[tuple[str, str]]] = None, auth: Optional[tuple[str, str]] = None, content_type: Optional[str] = None, **kwargs)[source]#

Performs a JSON request.

Parameters
  • url – The request URL.

  • method – The request method.

  • json_data – The JSON data to be submitted.

  • kwargs – Any custom parameters that are accepted by the ‘request’ method.

Returns

See the ‘request’ method.

login(email: Optional[str] = None, passw: Optional[str] = None, username: Optional[str] = None, force: bool = False, clear_last_doc: bool = True, manual: bool = False, add: bool = False, **kwargs)[source]#

Logs a user in.

Parameters
  • username – The username of the user.

  • email – The email of the user.

  • passw – The password of the user.

  • force – Whether to force the login route to be called even if the user is already logged in.

  • add – Whether to add this user to the session group.

  • manual – If true, always executes the login manually (without quick user context creation).

Returns

Response as a JSON dict.

login_anonymous()[source]#
login_test1(force: bool = False, add: bool = False, **kwargs)[source]#

Logs testuser1 in.

Parameters
  • force – Whether to force the login route to be called even if the user is already logged in.

  • add – Whether to add this user to the session group.

Returns

Response as a JSON dict.

login_test2(force: bool = False, add: bool = False, **kwargs)[source]#

Logs testuser2 in.

Parameters
  • force – Whether to force the login route to be called even if the user is already logged in.

  • add – Whether to add this user to the session group.

Returns

Response as a JSON dict.

login_test3(force: bool = False, add: bool = False, **kwargs)[source]#

Logs testuser3 in.

Parameters
  • force – Whether to force the login route to be called even if the user is already logged in.

  • add – Whether to add this user to the session group.

Returns

Response as a JSON dict.

logout(user_id: Optional[int] = None)[source]#

Logs the specified user out.

Parameters

user_id – The id of the user to log out. If None, everyone in the session gets logged out.

Returns

Response as a JSON dict.

make_admin(u: timApp.user.user.User)[source]#
make_base64(d: dict)[source]#

Converts the given dict to a base64-encoded JSON string.

mark_as_read(doc: timApp.document.docinfo.DocInfo, par_id: str, read_type=ReadParagraphType.click_red, **kwargs)[source]#
mark_as_unread(doc: timApp.document.docinfo.DocInfo, par_id, expect_status=200)[source]#
new_par(doc: timApp.document.document.Document, text: str, next_id: Optional[str] = None, additional_data=None, **kwargs)[source]#

Posts a new paragraph in a document.

Parameters
  • additional_data – Additional data to pass in newParagraph route.

  • doc – The document to be edited.

  • text – The text for the paragraph.

  • next_id – The id of the paragraph following the new paragraph.

Returns

The response object.

ok_resp = {'status': 'ok'}#
paste(doc: timApp.document.docinfo.DocInfo, par_before: Optional[timApp.document.docparagraph.DocParagraph] = None, par_after: Optional[timApp.document.docparagraph.DocParagraph] = None, as_ref: bool = False, **kwargs)[source]#
permission_error = {'error': "Sorry, you don't have permission to use this resource."}#
post(url: str, as_tree: bool = False, expect_status: int | None = 200, expect_content: Union[None, str, dict, list] = None, expect_contains: Optional[Union[str, list[str]]] = None, expect_xpath: Optional[str] = None, json_key: Optional[str] = None, headers: Optional[list[tuple[str, str]]] = None, **kwargs)[source]#

Performs a POST request.

See the ‘request’ method for parameter explanations.

post_answer(plugin_type, task_id: str, user_input, save_teacher=False, teacher=False, user_id=None, answer_id=None, ref_from=None, expect_content=None, expect_status=200, **kwargs)[source]#
post_answer_no_abdata(plugin_type, task_id, user_input, ref_from=None, **kwargs)[source]#
post_area(doc: timApp.document.docinfo.DocInfo, text: str, area_start: str, area_end: str, **kwargs)[source]#

Edits an area in a document.

Parameters
  • doc – The document to be edited.

  • text – The new text for the paragraph.

Returns

The response object.

post_comment(par: timApp.document.docparagraph.DocParagraph, public: bool, text: str, orig: Optional[timApp.document.docparagraph.DocParagraph] = None, **kwargs)[source]#
post_par(doc: timApp.document.document.Document, text: str, par_id: str, extra_data=None, **kwargs)[source]#

Edits a paragraph in a document.

Parameters
  • doc – The document to be edited.

  • text – The new text for the paragraph.

  • par_id – The id of the paragraph to be edited.

Returns

The response object.

post_preview(d: timApp.document.docinfo.DocInfo, text: str, spellcheck=False, par_next=None, par=None, **kwargs)[source]#
print_html(e: lxml.html.HtmlElement)[source]#
refresh_client()[source]#

Refreshes the Flask TestClient instance by emulating “with” statement exit and entrance. This method shouldn’t have to be called very often, but it appears to be necessary in rare cases (see test_caching).

request(url: str, method: str, as_tree: bool = False, as_response: bool = False, expect_status: int | None = 200, expect_content: Union[None, str, dict, list] = None, expect_contains: Optional[Union[str, list[str]]] = None, expect_mimetype: Optional[str] = None, expect_xpath: Optional[str] = None, expect_cookie: Optional[tuple[str, str | None]] = None, json_key: Optional[str] = None, headers: Optional[list[tuple[str, str]]] = None, xhr=True, auth: Optional[tuple[str, str]] = None, force_return_text=False, **kwargs) flask.wrappers.Response | str | dict[source]#

Performs a request.

For JSON POST/PUT requests, use the shortcut json_* methods.

Parameters
  • url – The request URL.

  • method – The request method (e.g. GET, POST, PUT, DELETE).

  • as_tree – Whether to return the response as an HTML tree.

  • expect_status – The expected status code.

  • expect_content – The expected response content. * If the response is a redirect, this parameter is interpreted as the expected redirect target URL. * Otherwise, if as_tree is True, this parameter is not used. * Otherwise, if the response mimetype is application/json, this parameter is interpreted as a dictionary or list that must match the response content. * Otherwise, this parameter is interpreted as a string that must match the response content.

  • expect_contains – The expected subset(s) of the response content. This can be a string or a list of strings.

  • expect_xpath – The expected XPath expression that must match at least one element in the response tree. This parameter can also be used for JSON responses as long as json_key is provided and the data in that key is HTML.

  • expect_cookie – Cookie key and value as a tuple. The value can be None to check if cookie doesn’t exist.

  • json_key – The expected key that is found in the returned JSON data. Any other data is discarded.

  • headers – Custom headers for the request.

  • kwargs – Custom parameters to be passed to test client’s ‘open’ method. Can be, for example, query_string={‘a’: ‘1’, ‘b’: ‘2’} for passing URL arguments.

Returns

If as_tree is True: Returns the response as an HTML tree. Otherwise, if the response mimetype is application/json, returns the response as a JSON dict or list. Otherwise, returns the response as a string.

classmethod setUpClass()[source]#

Hook method for setting up class fixture before running tests in the class.

show(doc: timApp.document.docinfo.DocInfo)[source]#
temp_config(settings: dict[str, Any])[source]#
update_whole_doc(doc: timApp.document.docinfo.DocInfo, text: str, **kwargs)[source]#
upload_file(d: timApp.document.docinfo.DocInfo, content: bytes, filename: str, **extra_data)[source]#
verify_answer_content(task: str, content_field: str | None, content, u: timApp.user.user.User, expected_count=1)[source]#
timApp.tests.server.timroutetest.fast_getaddrinfo(host, port, family=0, addrtype=0, proto=0, flags=0)[source]#

On Windows/Boot2docker, the getaddrinfo function is really slow, so we wrap the function and cache the result.

timApp.tests.server.timroutetest.get_content(element: lxml.html.HtmlElement, selector: str = '.parContent') list[str][source]#

Get value of the cookie with given key.

Parameters
  • resp – Response.

  • key – Cookie key.

Returns

Cookie value as string, or None if not found.

timApp.tests.server.timroutetest.get_note_id_from_json(json)[source]#
timApp.tests.server.timroutetest.is_redirect(response: flask.wrappers.Response)[source]#
timApp.tests.server.timroutetest.load_json(resp: flask.wrappers.Response)[source]#

Module contents#