intercom_test.http_best_matches module

Module for finding nearest imperfect match for HTTP request

class intercom_test.http_best_matches.AvailableAdditionalFieldsReport(available_value_sets)[source]

Bases: intercom_test.http_best_matches.Report

as_jsonic_data()[source]

Convert this report to JSON data

class intercom_test.http_best_matches.AvailableHttpMethodsReport(methods)[source]

Bases: intercom_test.http_best_matches.Report

as_jsonic_data()[source]

Convert this report to JSON data

class intercom_test.http_best_matches.AvailableJsonRequestBodiesReport(diff_case_pairs)[source]

Bases: intercom_test.http_best_matches.Report

as_jsonic_data()[source]

Convert this report to JSON data

class intercom_test.http_best_matches.AvailablePathsReport(test_case_groups)[source]

Bases: intercom_test.http_best_matches.Report

as_jsonic_data()[source]

Convert this report to JSON data

class intercom_test.http_best_matches.AvailableQueryStringParamsetsReport(deltas)[source]

Bases: intercom_test.http_best_matches.Report

as_jsonic_data()[source]

Convert this report to JSON data

class intercom_test.http_best_matches.AvailableScalarRequestBodiesReport(test_cases)[source]

Bases: intercom_test.http_best_matches.Report

as_jsonic_data()[source]

Convert this report to JSON data

class intercom_test.http_best_matches.Database(cases: Iterable[dict], *, add_request_keys=())[source]

Bases: object

best_matches(request: dict, *, timeout: float = 0.3) → dict[source]

Given HTTP request parameters, find the best known match

get_case(request: dict)[source]
json_exchange(request_json, reply_stream)[source]
class intercom_test.http_best_matches.JsonComparer(ref)[source]

Bases: object

Utility to compare one JSON document with several others

CONGRUENT_DATA = 'congruent options'
class Delta[source]

Bases: tuple

Differences between two JSON documents

This difference always consists of three parts, in decreasing order of precedence:

  • Changes to which substructures are present,
  • Changes to where substructures are located, and
  • Changes to scalar values.

Only one of these three will be non-empty.

Use distance() to get a sortable distance measure for this delta.

edit_distance()[source]
scalar_diffs
structure_diffs
structure_location_diffs
diff(case) → intercom_test.http_best_matches.JsonComparer.Delta[source]

Diffs two JSON documents

The difference evaluation proceeds in three steps, with each of the later steps proceeding only if the earlier step produced no differences.

The steps are:

  • All substructures (lists and dicts, with correct subitem signatures) are present.
  • All substructures are in the correct locations.
  • Each scalar value location holds the expected scalar value.

To reflect this, the differences are returned as a tuple of three Sequence`s wrapped in a :class:.JsonComparer.Delta`, only one of which will contain any items:

  • Changes to which substructures are present.
  • Changes to where substructures are located.
  • Changes to scalar values.
class intercom_test.http_best_matches.JsonMap(json_data)[source]

Bases: object

items_from_signature(sig)[source]
scalars

Indexes correspond with scalar_key_paths()

substruct_key_paths

Indexes correspond with substruct_signatures()

substruct_locations
substruct_signatures

Indexes correspond with substruct_key_paths()

class intercom_test.http_best_matches.JsonType

Bases: enum.IntEnum

An enumeration.

NoneType = 1
construct()
dict = 6
float = 4
int = 3
is_collection
list = 5
str = 2
class intercom_test.http_best_matches.JsonWalker[source]

Bases: object

walk(json_data)[source]
class intercom_test.http_best_matches.QStringComparer(qsparams: Sequence[Tuple[str, str]])[source]

Bases: object

Utility to compare one URL query string with several others

class Delta[source]

Bases: tuple

edits
mods
params
diff(case_qsparams: Sequence[Tuple[str, str]])[source]
class intercom_test.http_best_matches.Report[source]

Bases: abc.ABC

as_jsonic_data()[source]

Convert this report to JSON data

intercom_test.http_best_matches.lookup_json_type()

Return the value for key if key is in the dictionary, else default.