webutil.tests package

Submodules

webutil.tests.test_flask_util module

webutil.tests.test_logs module

Unit tests for logs.py. Woefully incomplete.

class LogsTest(methodName='runTest')[source]

Bases: TestCase

setUp()[source]
test_url()[source]
test_start_time_too_old()[source]
test_start_time_too_far_future()[source]

webutil.tests.test_models module

Unit tests for models.py.

class ReloaderTest(methodName='runTest')[source]

Bases: TestCase

setUp()[source]
test_loads_on_first_access(mock_now)[source]
test_returns_none_if_missing()[source]
test_caches_within_interval(mock_now)[source]
test_reloads_after_interval(mock_now)[source]
test_reload(mock_now)[source]
class StringIdModelTest(methodName='runTest')[source]

Bases: TestCase

setUp()[source]
test_put()[source]
class TestEnum(*values)[source]

Bases: Enum

FOO = 1
BAR = 2
class EnumModel(**kwargs)[source]

Bases: Model

field

Property for storing Python Enum values.

Stores the enum’s integer value in the datastore.

class EnumPropertyTest(methodName='runTest')[source]

Bases: TestCase

test_init_non_enum()[source]
test_validate()[source]
test_round_trip()[source]
class EncryptedModel(**kwargs)[source]

Bases: Model

secret

Property that stores encrypted bytes.

Encrypts bytes values using AES-256-GCM before storing in the datastore, and decrypts them when reading back.

The AES-256-GCM key(s) should be in the encrypted_property_key file, base64 encoded, one per line. Encryption always uses the first key. For decryption, each key is tried in order until one succeeds.

Multiple keys are used during key rotation: add the new key as the first line and keep the old key as the second line. New writes will use the new key, and existing ciphertexts encrypted with the old key will still decrypt via fallback. Once all stored values have been re-encrypted with the new key, remove the old key.

Here’s example code to generate an AES-256-GCM key and base64 encode it:

import base64 from cryptography.hazmat.primitives.ciphers.aead import AESGCM

key_bytes = AESGCM.generate_key(bit_length=256) print(base64.b64encode(key_bytes))

class EncryptedPropertyTest(methodName='runTest')[source]

Bases: TestCase

setUp()[source]
tearDown()[source]
test_validate()[source]
test_round_trip()[source]
test_encrypted_storage()[source]
test_none_value()[source]
test_no_key_error()[source]
test_different_nonces()[source]
test_decrypt_falls_back_to_later_key()[source]
test_decrypt_fails_when_no_key_matches()[source]
test_write_once()[source]

webutil.tests.test_util module

webutil.tests.test_webmention module

Unit tests for webmention.py.

class DiscoverTest(methodName='runTest')[source]

Bases: TestCase

test_bad_url()[source]
test_no_endpoint()[source]
test_html_a()[source]
test_html_refresh()[source]
test_html_relative()[source]
test_html_rel_url()[source]
test_html_empty()[source]
test_html_unicode()[source]
test_html_escaped()[source]
test_html_content_type_html()[source]
test_html_content_type_html_charset()[source]
test_html_content_type_other()[source]
test_header()[source]
test_header_relative()[source]
test_header_quoted()[source]
test_header_rel_url()[source]
test_other_headers()[source]
test_header_empty()[source]
test_header_query_params()[source]
test_header_fragment()[source]
test_header_unicode()[source]
test_header_escaped()[source]
test_http_500()[source]
test_connection_error(_)[source]
class SendTest(methodName='runTest')[source]

Bases: TestCase

test_bad_url()[source]
test_success()[source]
test_requests_exception()[source]
test_preserve_endpoint_query_params()[source]
test_unicode_urls()[source]
test_unicode_urls_escaped()[source]

Module contents