mementoweb.validator.tests package

Submodules

mementoweb.validator.tests.content_type_header_test module

class mementoweb.validator.tests.content_type_header_test.ContentTypeHeaderTest

Bases: mementoweb.validator.tests.test.

CONTENT_TYPE_MATCH = 'Content type match'
CONTENT_TYPE_MISMATCH = 'Content type mismatch'
CONTENT_TYPE_NOT_PRESENT = 'Content-type not present for Time-map'
CONTENT_TYPE_PRESENT = 'Content-type present for Time-map'
test(response: mementoweb.validator.util.http.HttpResponse, content_type: Optional[str] = None) mementoweb.validator.tests.test.TestReport

Perform the test the specified test need to perform

Parameters

**kwargs

Returns

List[TestResult]

mementoweb.validator.tests.datetime_negotiation_test module

class mementoweb.validator.tests.datetime_negotiation_test.DatetimeNegotiationTest

Bases: mementoweb.validator.tests.test.

CONTENT_NEGOTIATION_HEADERS_NOT_PRESENT = 'Resource does not support datetime negotiation'
CONTENT_NEGOTIATION_HEADERS_PRESENT = 'Resource supports datetime negotiation'
HEADERS_NOT_PRESENT = 'Response headers not present'
test(response: mementoweb.validator.util.http.HttpResponse) mementoweb.validator.tests.test.TestReport

Perform the test the specified test need to perform

Parameters

**kwargs

Returns

List[TestResult]

mementoweb.validator.tests.header_test module

class mementoweb.validator.tests.header_test.HeaderTest

Bases: mementoweb.validator.tests.test.

ACCEPT_DATETIME_IN_VARY = 'Accept-Datetime in Vary header'
ACCEPT_DATETIME_NOT_IN_VARY = 'Accept-Datetime not in Vary header'
CONTENT_LOCATION_NOT_PRESENT = 'Location/ Content-Location header not found'
CONTENT_LOCATION_PRESENT = 'Content-Location Header found'
HEADERS_NOT_PRESENT = 'Headers not present'
LOCATION_FOUND = 'Location Header found'
VARY_NOT_FOUND = 'Vary header not found'
test(response: mementoweb.validator.util.http.HttpResponse, resource_type: mementoweb.validator.validator_types.ResourceType = ResourceType.ORIGINAL) mementoweb.validator.tests.test.TestReport

Perform the test the specified test need to perform

Parameters

**kwargs

Returns

List[TestResult]

mementoweb.validator.tests.memento_redirect_test module

class mementoweb.validator.tests.memento_redirect_test.MementoRedirectTest

Bases: mementoweb.validator.tests.test.

Implements testing procedures and variables for testing Memento redirection.

BROKEN_REDIRECTION: str = 'Redirection URI broken'
INVALID_MEMENTO_STATUS: str = 'Memento does not contain status 200, 204, or 206'
MISSING_REDIRECTION_LOCATION: str = 'Missing location for redirection'
REDIRECTION_BEFORE_MEMENTO: str = 'Redirection before memento'
VALID_MEMENTO_STATUS: str = 'Memento contains status 200, 204, or 206'
test(response: mementoweb.validator.util.http.HttpResponse) mementoweb.validator.tests.memento_redirect_test.MementoRedirectTestReport

Test on redirection compliance for a given HTTP response.

Parameters

response – Http response for testing

Returns

Memento redirect test report

class mementoweb.validator.tests.memento_redirect_test.MementoRedirectTestReport(connection: Optional[mementoweb.validator.util.http.HttpConnection] = None, *args, **kwargs)

Bases: mementoweb.validator.tests.test.TestReport

Test report for Memento redirection. Includes updated redirected HTTP connection.

connection: mementoweb.validator.util.http.HttpConnection = None

mementoweb.validator.tests.test module

class mementoweb.validator.tests.test.BaseTest

Bases: object

Abstraction for a test

add_test_result(test_result: mementoweb.validator.tests.test.TestResult)
test(**kwargs: dict) mementoweb.validator.tests.test.TestReport

Perform the test the specified test need to perform

Parameters

**kwargs

Returns

List[TestResult]

class mementoweb.validator.tests.test.TestInfo

Bases: TypedDict

connection: mementoweb.validator.util.http.HttpConnection
uri: str
class mementoweb.validator.tests.test.TestReport(report_status: int = - 1, description: str = '', name: str = '', tests: Optional[List[mementoweb.validator.tests.test.TestResult]] = None)

Bases: object

Abstraction to a test report/ results of collection of tests

REPORT_FAIL: int = -1
REPORT_PASS: int = 1
REPORT_WARN: int = 0
description: str
name: str
report_status: int
tests: List[mementoweb.validator.tests.test.TestResult]
to_json() dict
class mementoweb.validator.tests.test.TestResult(name: str = '', status: int = - 1, description: str = '')

Bases: object

Abstraction of a test result/ single test

TEST_FAIL: int = -1
TEST_INFO: int = 0
TEST_PASS: int = 2
TEST_WARN: int = 1
name()
result() str
to_json()

mementoweb.validator.tests.timegate_redirect_test module

class mementoweb.validator.tests.timegate_redirect_test.TimeGateBlankRedirectTest

Bases: mementoweb.validator.tests.timegate_redirect_test.

TIMEGATE_BLANK_INVALID_REDIRECT = 'TimeGate does not redirect to last memento without Accept-Datetime'
TIMEGATE_BLANK_INVALID_RETURN = 'Timegate does not return 302/200 for blank Accept-Datetime'
TIMEGATE_BLANK_VALID_REDIRECT = 'TimeGate redirects to last memento without Accept-Datetime'
TIMEGATE_BLANK_VALID_RETURN = 'TimeGate returns 200 or redirect for blank Accept-Datetime'
test(connection: mementoweb.validator.util.http.HttpConnection, datetime: str, redirect_threshold: int = 5) mementoweb.validator.tests.timegate_redirect_test.TimeGateRedirectTestReport

Test the redirection of the TimeGate resource provided as a HttpConnection for compliance with empty Accept-Datetime.

Parameters
  • connection – Primary connection for testing the redirection

  • datetime – Ignored

  • redirect_threshold – Ignored

Returns

Time gate redirection test report containing results

class mementoweb.validator.tests.timegate_redirect_test.TimeGateBrokenRedirectTest

Bases: mementoweb.validator.tests.timegate_redirect_test.

TIMEGATE_BROKEN_INVALID_RETURN = 'Timegate does not return 400 for broken datetime'
TIMEGATE_BROKEN_VALID_RETURN = 'TimeGate returns 400 for broken datetime'
test(connection: mementoweb.validator.util.http.HttpConnection, datetime: str, redirect_threshold: int = 5) mementoweb.validator.tests.timegate_redirect_test.TimeGateRedirectTestReport

Test the redirection of the TimeGate resource provided as a HttpConnection for compliance with unparsable Accept-Datetime.

Parameters
  • connection – Primary connection for testing the redirection

  • datetime – Ignored

  • redirect_threshold – Ignored

Returns

Time gate redirection test report containing results

class mementoweb.validator.tests.timegate_redirect_test.TimeGateFutureRedirectTest

Bases: mementoweb.validator.tests.timegate_redirect_test.

TIMEGATE_FUTURE_INVALID_REDIRECT = 'TimeGate does not redirect to first memento for datetime in past'
TIMEGATE_FUTURE_INVALID_RETURN = 'Timegate does not return 302 for datetime in future'
TIMEGATE_FUTURE_VALID_REDIRECT = 'TimeGate redirects to first memento for datetime in past'
TIMEGATE_FUTURE_VALID_RETURN = 'TimeGate returns 302 for datetime in future'
test(connection: mementoweb.validator.util.http.HttpConnection, datetime: str, redirect_threshold: int = 5) mementoweb.validator.tests.timegate_redirect_test.TimeGateRedirectTestReport

Test the redirection of the TimeGate resource provided as a HttpConnection for compliance with Accept-Datetime in future.

Parameters
  • connection – Primary connection for testing the redirection

  • datetime – Ignored

  • redirect_threshold – Ignored

Returns

Time gate redirection test report containing results

class mementoweb.validator.tests.timegate_redirect_test.TimeGatePastRedirectTest

Bases: mementoweb.validator.tests.timegate_redirect_test.

TIMEGATE_PAST_INVALID_REDIRECT = 'TimeGate does not redirect to first memento for datetime in past'
TIMEGATE_PAST_INVALID_RETURN = 'Timegate does not return 302 for datetime in past'
TIMEGATE_PAST_VALID_REDIRECT = 'TimeGate redirects to first memento for datetime in past'
TIMEGATE_PAST_VALID_RETURN = 'TimeGate returns 302 for datetime in past'
test(connection: mementoweb.validator.util.http.HttpConnection, datetime: str, redirect_threshold: int = 5) mementoweb.validator.tests.timegate_redirect_test.TimeGateRedirectTestReport

Test the redirection of the TimeGate resource provided as a HttpConnection for compliance with Accept-Datetime in past (before first memento).

Parameters
  • connection – Primary connection for testing the redirection

  • datetime – Ignored

  • redirect_threshold – Ignored

Returns

Time gate redirection test report containing results

class mementoweb.validator.tests.timegate_redirect_test.TimeGateRedirectTest

Bases: mementoweb.validator.tests.test.

Implements testing procedures/ variables for testing TimeGate redirection.

BROKEN_REDIRECTION = 'Redirection URI broken'
MISSING_REDIRECTION_LOCATION = 'Missing location for redirection'
REDIRECTION_BEFORE_TIMEGATE = 'Redirection before timegate'
REDIRECTION_MISSING_ORIGINAL = 'Redirection to another timegate'
REDIRECT_THRESH_PASSED = 'Redirect threshold passed'
TIMEGATE_INVALID_RETURN = 'TimeGate does not return 302/ 200'
TIMEGATE_RETURN_200 = 'TimeGate returns 200'
TIMEGATE_RETURN_302 = 'TimeGate returns 302'
TIMEGATE_RETURN_307 = 'TimeGate returns 307'
test(connection: mementoweb.validator.util.http.HttpConnection, datetime: str, redirect_threshold: int = 5) mementoweb.validator.tests.timegate_redirect_test.TimeGateRedirectTestReport

Test the redirection of the TimeGate resource provided as a HttpConnection.

Parameters
  • connection – Primary connection for testing the redirection

  • datetime – Datetime used for establishing the primary connection. Should conform the standard specification

  • redirect_threshold – Maximum number of redirects for warning

Returns

Time gate redirection test report containing results

class mementoweb.validator.tests.timegate_redirect_test.TimeGateRedirectTestReport(connection: Optional[mementoweb.validator.util.http.HttpConnection] = None, *args, **kwargs)

Bases: mementoweb.validator.tests.test.TestReport

Test report from testing Timegate redirection. Includes updated HTTP connection based on the type of test.

connection: mementoweb.validator.util.http.HttpConnection = None

mementoweb.validator.tests.timemap_parse_test module

class mementoweb.validator.tests.timemap_parse_test.TimeMapParseTest

Bases: mementoweb.validator.tests.test.

Implements testing procedures/ variables for testing Timemap resource body.

MEMENTO_DATETIME_NOT_PARSABLE = 'Memento datetime not parsable'
MEMENTO_DATETIME_NOT_PRESENT = 'Memento does not contain datetime attribute'
MEMENTO_DATETIME_PARSABLE = 'Memento datetime parsable'
MEMENTO_DATETIME_PRESENT = 'Memento contains datetime attribute'
TIMEMAP_NOT_PARSABLE = 'TimeMap not parsable'
TIMEMAP_PARSABLE = 'TimeMap Parsable'
test(response: mementoweb.validator.util.http.HttpResponse, full_test=False) mementoweb.validator.tests.test.TestReport

Tests the parsability/ validity of timemap resource body of a given Http response.

Parameters
  • response – Http response for testing

  • full_test – Toogle full tests. Individually test each

memento and test the parsability of corresponding datetime. :return: Base test report containing test results.

mementoweb.validator.tests.timemap_redirect_test module

class mementoweb.validator.tests.timemap_redirect_test.TimeMapRedirectTest

Bases: mementoweb.validator.tests.test.

Implements testing procedures/ variables for testing redirection of a timemap resource.

TIMEMAP_INVALID_RETURN = 'TimeMap does not return 200'
TIMEMAP_VALID_RETURN = 'TimeMap returns 200'
test(response: mementoweb.validator.util.http.HttpResponse) mementoweb.validator.tests.test.TestReport

Performs timemap redirection tests for a given HTTP response.

Parameters

response – HTTP response for testing

Returns

Base test report containing test results.

mementoweb.validator.tests.uri_test module

class mementoweb.validator.tests.uri_test.URITest

Bases: mementoweb.validator.tests.test.

Implements URI validation and connectivity tests.

CONNECTION_FAIL: str = 'Could not connect to URI'
INVALID_URI: str = 'Invalid URI'
REQUEST_FAIL: str = 'HTTP(s) Request Failed'
VALID_URI: str = 'Valid URI'
test(uri: str, datetime: str, method='HEAD') mementoweb.validator.tests.uri_test.URITestReport

Performs URI testing on a given uri

Parameters
  • uri – URI for testing/ required

  • datetime – datetime for testing/ only used when URI is valid and on establishing connection

Returns

class mementoweb.validator.tests.uri_test.URITestReport(connection: Optional[mementoweb.validator.util.http.HttpConnection] = None, *args, **kwargs)

Bases: mementoweb.validator.tests.test.TestReport

URITestReport encapsulates URI test specific results in addition to standard test results.

connection: mementoweb.validator.util.http.HttpConnection = None

Module contents