timApp.tests.server package
Contents
timApp.tests.server package#
Submodules#
timApp.tests.server.race module#
Server tests for race conditions.
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
- test_access_lock_document_access()[source]#
Test that locking access does not affect document access rules.
timApp.tests.server.test_account_delete module#
timApp.tests.server.test_admin module#
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]#
timApp.tests.server.test_area_behavior module#
- class timApp.tests.server.test_area_behavior.AreaTest(methodName='runTest')[source]#
timApp.tests.server.test_autocounters module#
A test for markdownconverter module.
timApp.tests.server.test_bookmarks module#
- class timApp.tests.server.test_bookmarks.BookmarkTest2(methodName='runTest')[source]#
Bases:
timApp.tests.server.test_bookmarks.BookmarkTestBase
- refresh(i: timApp.document.docinfo.DocInfo)[source]#
timApp.tests.server.test_broken_db module#
timApp.tests.server.test_caching module#
Server tests for document caching.
timApp.tests.server.test_calendar module#
Server tests for TIM-calendar
- class timApp.tests.server.test_calendar.CalendarTest(methodName='runTest')[source]#
timApp.tests.server.test_cbcountfield module#
Server tests for cbcountfield.
timApp.tests.server.test_clipboard module#
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]#
timApp.tests.server.test_copy_cite module#
timApp.tests.server.test_courses module#
timApp.tests.server.test_create_db module#
timApp.tests.server.test_csplugin module#
timApp.tests.server.test_default_rights module#
timApp.tests.server.test_dist_rights module#
- class timApp.tests.server.test_dist_rights.DistRightsProcessor(dt: datetime.datetime, target_name: str)[source]#
Bases:
object
- dt: datetime.datetime#
- target_name: str#
- class timApp.tests.server.test_dist_rights.DistRightsTest(methodName='runTest')[source]#
Bases:
timApp.tests.server.timroutetest.TimRouteTest
- 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#
timApp.tests.server.test_doc_partition module#
timApp.tests.server.test_doc_sass module#
Server tests for xxx.
timApp.tests.server.test_doc_settings module#
timApp.tests.server.test_duration module#
- class timApp.tests.server.test_duration.DurationTest(methodName='runTest')[source]#
Bases:
timApp.tests.server.timroutetest.TimRouteTest
- 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_duplicate_template()[source]#
Trying to load a template to a non-empty document is not possible.
- test_no_area_start_update()[source]#
getUpdatedPars shouldn’t return area start or end pars because it will break the DOM structure.
timApp.tests.server.test_feedback_report module#
timApp.tests.server.test_folders module#
- class timApp.tests.server.test_folders.FolderCopyTest(methodName='runTest')[source]#
timApp.tests.server.test_graphviz module#
Server tests for graphviz plugin.
timApp.tests.server.test_grouplogin module#
timApp.tests.server.test_groups module#
timApp.tests.server.test_hide_names module#
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
- class timApp.tests.server.test_importdata.ImportDataTest(*args, **kwargs)[source]#
Bases:
timApp.tests.server.test_importdata.ImportDataTestBase
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]#
timApp.tests.server.test_inlineplugins module#
timApp.tests.server.test_ip_block module#
Server tests for IP blocking.
timApp.tests.server.test_item_create module#
- class timApp.tests.server.test_item_create.ItemCreateTest(methodName='runTest')[source]#
timApp.tests.server.test_jsrunner module#
Server tests for jsrunner plugin.
- class timApp.tests.server.test_jsrunner.JsRunnerTestBase(methodName='runTest')[source]#
Bases:
timApp.tests.server.timroutetest.TimRouteTest
- 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#
timApp.tests.server.test_late_answers module#
Server tests for xxx.
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]#
timApp.tests.server.test_macros module#
Server tests for macros.
timApp.tests.server.test_manage module#
timApp.tests.server.test_math module#
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
- class timApp.tests.server.test_messagelist.MessageListTest(methodName='runTest')[source]#
Bases:
timApp.tests.server.timroutetest.TimMessageListTest
Server test for message lists.
timApp.tests.server.test_minutes module#
timApp.tests.server.test_notify module#
- 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]#
timApp.tests.server.test_oauth2 module#
timApp.tests.server.test_par_diff module#
Server tests for getParDiff route.
timApp.tests.server.test_par_visibility module#
Server tests for user/view-specific document rendering.
timApp.tests.server.test_password_hashing module#
Tests for password hashing.
timApp.tests.server.test_peer_review module#
Server tests for peer review.
timApp.tests.server.test_permissions module#
- class timApp.tests.server.test_permissions.PermissionTest(methodName='runTest')[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."}#
- do_plugin_upload(d: timApp.document.docinfo.DocInfo, file_content, filename, task_id, task_name, expect_version=1)[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_user_modifiers()[source]#
Save and show answers according to global field and useCurrentUser logic
- test_timtable_nonexistent_route()[source]#
Calling non-existent timTable route won’t result in an infinite request loop.
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]#
timApp.tests.server.test_preamble module#
Server tests for preamble.
timApp.tests.server.test_preview module#
Server tests for preview.
- class timApp.tests.server.test_preview.PreviewTest(methodName='runTest')[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#
timApp.tests.server.test_question module#
- class timApp.tests.server.test_question.QuestionTest(*args, **kwargs)[source]#
Bases:
timApp.tests.browser.browsertest.BrowserTest
timApp.tests.server.test_quicklogin module#
timApp.tests.server.test_random module#
Server tests for randomization.
timApp.tests.server.test_readings module#
- class timApp.tests.server.test_readings.ReadingsTest(methodName='runTest')[source]#
Bases:
timApp.tests.server.timroutetest.TimRouteTest
- get_readings(doc: timApp.document.docinfo.DocInfo)[source]#
timApp.tests.server.test_referencing module#
timApp.tests.server.test_relevance module#
timApp.tests.server.test_replace module#
timApp.tests.server.test_sanitize module#
Server tests for verifying the absence of XSS or other DOM sanitization issues in certain scenarios.
timApp.tests.server.test_scheduled_functions module#
timApp.tests.server.test_scim module#
- class timApp.tests.server.test_scim.ScimTest(methodName='runTest')[source]#
timApp.tests.server.test_scoreboard module#
Server tests for scoreboard.
timApp.tests.server.test_search module#
timApp.tests.server.test_settings module#
timApp.tests.server.test_showfile module#
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]#
- mock_missing_uniquecode: bool = False#
- 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]#
- 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_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.
timApp.tests.server.test_slide module#
timApp.tests.server.test_tableform module#
timApp.tests.server.test_teacher module#
Server tests for xxx.
timApp.tests.server.test_templates module#
timApp.tests.server.test_themes module#
timApp.tests.server.test_tim module#
Unit tests for TIM routes.
timApp.tests.server.test_tim_message module#
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.
- 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]#
timApp.tests.server.test_upload module#
timApp.tests.server.test_url_redirect module#
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.
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
timApp.tests.server.test_verification module#
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
]
- 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.
- 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_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.
- 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_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#
- 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_task_answers(task_id, user: Optional[timApp.user.user.User] = None)[source]#
- get_updated_pars(d: timApp.document.docinfo.DocInfo, **kwargs)[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_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]#
- 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_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]#
- 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]#
- 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]#