AKModel.tests.test_protocol_migration module

class AKModel.tests.test_protocol_migration.ProtocolMigrationLinkTests(methodName='runTest')[source]

Bases: TestCase

Test parsing of HedgeDoc and wiki links

test_hedgedoc_download_url()[source]

Test that note links (on any instance) are translated to download links and other links are rejected

test_wiki_page_title()[source]

Test that wiki links are translated to page titles and other links are rejected

class AKModel.tests.test_protocol_migration.ProtocolMigrationTests(methodName='runTest')[source]

Bases: TestCase

Test the migration of single protocols with mocked HedgeDoc, pandoc and wiki

test_success_missing_page()[source]

Test migration to a page that does not exist yet

test_success_empty_page()[source]

Test migration to an existing but empty page

test_page_not_empty()[source]

Test that non-empty pages are not touched

Test that missing or invalid links are reported without contacting any service

test_download_failed()[source]

Test handling of notes that cannot be downloaded (e.g., redirect to login)

test_empty_protocol()[source]

Test that empty protocols are not written to the wiki

test_wiki_error()[source]

Test handling of errors when writing to the wiki (e.g., edit conflicts)

test_unexpected_error()[source]

Test that unexpected errors are reported for the AK instead of aborting the whole migration

AKModel.tests.test_protocol_migration.hedgedoc_response(status_code=200, content=None, content_type='text/markdown; charset=UTF-8', location=None)[source]

Create a mocked (streamed) response of HedgeDoc

Parameters:

content – list of chunks of the body or an exception to raise when reading it

AKModel.tests.test_protocol_migration.api_response(data, status_code=200)[source]

Create a mocked response of the MediaWiki API

AKModel.tests.test_protocol_migration.token_response(token_type, token)[source]

Create a mocked response of the MediaWiki API to a token query

class AKModel.tests.test_protocol_migration.MediaWikiClientTests(methodName='runTest')[source]

Bases: TestCase

Test the MediaWiki API client with a mocked HTTP session

test_get_page_existing()[source]

Test retrieving content and timestamp of an existing page

test_get_page_missing()[source]

Test retrieving a page that does not exist

test_get_page_login()[source]

Test that the login is performed before reading (wikis may require it for reading)

test_get_page_invalid_title()[source]

Test that invalid titles are reported as invalid wiki links

test_get_page_not_regular()[source]

Test that special pages and interwiki titles are reported as invalid wiki links

test_get_page_unexpected_response()[source]

Test that a page without revisions is reported as wiki error

test_request_errors()[source]

Test that network errors, HTTP errors, API errors and invalid responses are reported as wiki errors

test_login()[source]

Test login with bot password and retrieval of csrf token

test_login_cached()[source]

Test that logins are stored in the cache and reused by new clients (e.g., in the next request)

test_login_expired()[source]

Test that expired (e.g., cached) logins are detected and renewed

test_login_failed()[source]

Test that a failed login is reported and no token is stored

test_anonymous()[source]

Test that no login is performed when no credentials are configured

test_write_missing_page()[source]

Test that missing pages are only created, never overwritten

test_write_empty_page()[source]

Test that existing empty pages are edited with edit conflict detection

test_write_conflict()[source]

Test that pages created in the meantime (edit conflict) are reported as errors

test_write_not_successful()[source]

Test that unsuccessful edits without API error (e.g., captcha or abuse filter) are reported

class AKModel.tests.test_protocol_migration.ProtocolDownloadAndConversionTests(methodName='runTest')[source]

Bases: TestCase

Test downloading protocols from HedgeDoc and converting them using pandoc (via pypandoc)

test_download()[source]

Test successful download (decoded as UTF-8)

test_download_failed()[source]

Test that HTTP errors, redirects (e.g., to login), network errors and other content are reported

test_resolve_public_address()[source]

Test that only hosts with public addresses are accepted

test_fetch_public()[source]

Test that requests are sent to the checked address while TLS still uses the hostname

test_convert()[source]

Test conversion of markdown to MediaWiki syntax using the bundled pandoc

test_download_redirects()[source]

Test that redirects are only followed to download URLs of notes

test_convert_hedgedoc_specifics()[source]

Test that single line breaks are kept and YAML metadata is dropped (as rendered by HedgeDoc)

test_convert_pandoc_call()[source]

Test that pandoc is called with the right formats and sandboxed

test_convert_failed()[source]

Test that pandoc errors and a missing pandoc are reported

class AKModel.tests.test_protocol_migration.MigrateProtocolsTests(methodName='runTest')[source]

Bases: TestCase

Test the migration of multiple protocols

test_wiki_client_reused()[source]

Test that one wiki client (and hence one login) is used for all AKs on the same wiki and that results are returned in the order of the AKs

class AKModel.tests.test_protocol_migration.ProtocolMigrationViewTests(methodName='runTest')[source]

Bases: TestCase

Test the admin action and views for protocol migration

test_admin_action()[source]

Test that the admin action redirects to the confirmation view with the selected AKs

test_confirmation()[source]

Test that the confirmation page renders and lists the AKs with their links

test_result()[source]

Test that the report page lists the AKs with one migration URL each but does not migrate anything itself

test_migrate_single()[source]

Test the migration of a single AK triggered from the report page

test_migrate_single_errors()[source]

Test that the single migration only accepts POST requests for existing AKs

test_change_permission_required()[source]

Test that staff users without permission to change AKs can neither see the action nor migrate protocols

test_action_hidden_without_configuration()[source]

Test that the action is only offered if wikis are configured

test_access_restricted()[source]

Test that anonymous and non-staff users can neither see the view nor trigger a migration