Test fakes#

class geonemo.client.fakes.FakeCatalogClient#

In-memory authoritative catalog fake; similarity uses shared retrieval.

add_collection(name, **metadata)#

Create a collection if needed and set its metadata.

add_record(record)#

Add a record, creating its collection if needed.

Raises:

ValueError – If a different record with the same ID already exists.

browse(request)#

List a collection’s records like CatalogClient.browse.

close()#

Do nothing; there is nothing to release.

collection_stats(collection)#

Count a collection’s records and find its acquisition time range.

facets(request)#

Count metadata values like CatalogClient.facets.

get_record(collection, record_id)#

Return the record, or None.

get_records(request)#

Return the records found and the IDs that were missing.

ingest(request, *, idempotency_key=None)#

Store records with the real idempotency rules.

Parameters:
  • request – Collection and records.

  • idempotency_key – Replay key; defaults to a hash of the request.

Returns:

The receipt; a replay returns duplicate=True.

Raises:
  • ValueError – If the key is malformed.

  • ServicesConflictError – If the key was used for a different request.

list_collections()#

List collections sorted by name.

metadata_fields(collection)#

Summarize the metadata fields of a collection’s records.

scan(request)#

Read one page of a full scan like CatalogClient.scan, in record ID order.

Raises:

ServicesNotFoundError – If the collection does not exist.

search(request)#

Search a collection like CatalogClient.search.

search_page(request)#

Search a collection like CatalogClient.search_page.

class geonemo.client.fakes.FakeGeoNeMoClient(
*,
project_id='default',
gkb=None,
catalog=None,
media=None,
status=None,
discovery=None,
)#

Aggregate offline fake mirroring the production client shape.

close()#

Close every fake area client.

discover()#

Return the configured discovery document.

class geonemo.client.fakes.FakeGkbClient(artifacts=())#

In-memory canonical GKB with real identity and idempotency semantics.

activity(project_id)#

List a project’s artifacts, newest first.

close()#

Do nothing; there is nothing to release.

contribute(draft, *, idempotency_key=None)#

Render and store a draft like GkbClient.contribute.

contribute_artifact(artifact, *, idempotency_key=None)#

Store an artifact with the real identity and idempotency rules.

A replay with the same key and content returns a receipt with duplicate=True.

Raises:
  • TypeError – If artifact is not a KnowledgeArtifact.

  • ServicesConflictError – If the key or artifact ID was used for different content.

get(artifact_id)#

Return the stored artifact, or None.

list_projects()#

List projects with their artifact counts and latest activity.

query(query)#

Filter stored artifacts by text, project, bounding box and time ranges like GkbClient.query.

Raises:

TypeError – If query is not an ArtifactQuery.

search(query)#

Return the hits of query.

Search with a numeric offset cursor, like GkbClient.structured_search.

structured_search_page(query)#

Search with a numeric offset cursor, like GkbClient.structured_search_page.

validate(artifact)#

Validate Markdown like GkbClient.validate; invalid input is reported in the result, not raised.

visualization(project_id)#

Return a project graph with one node per stored artifact and no edges.

class geonemo.client.fakes.FakeMediaClient#

In-memory catalog-media fake with the production client’s bounded shape.

add_georeferenced_window(
collection,
record_id,
*,
x,
y,
width,
height,
output_width=None,
output_height=None,
bands=None,
content,
asset=None,
)#

Register the content returned for one georeferenced window request.

Raises:

ValueError – If content does not declare a georeferencing method.

add_pixel(collection, record_id, pixel, *, asset=None)#

Register the pixel value at (pixel.x, pixel.y) of a record.

add_product_manifest(manifest, *, files)#

Register a complete product inventory and its immutable file bytes.

add_record(
inspection,
*,
preview=None,
download=None,
histogram=None,
asset=None,
)#

Register a record’s inspection and, optionally, its preview, download and histogram for one asset.

add_tile(
collection,
record_id,
*,
z,
x,
y,
content,
asset=None,
)#

Register the tile (z, x, y) of a record.

close()#

Do nothing; there is nothing to release.

download(
collection,
record_id,
*,
byte_range=None,
max_bytes=16777216,
asset=None,
)#

Return the registered download, or the requested byte range of it.

Raises:
download_to(
collection,
record_id,
destination,
*,
asset,
expected_byte_size,
expected_sha256,
expected_inventory_sha256=None,
expected_safe_relative_path=None,
resume=True,
chunk_size=1048576,
range_size=67108864,
)#

Write a registered product file to destination, like MediaClient.download_to.

Raises:
georeferenced_window(
collection,
record_id,
*,
x,
y,
width,
height,
output_width=None,
output_height=None,
bands=None,
max_bytes=16777216,
asset=None,
)#

Return the content registered for this window with add_georeferenced_window.

Raises:

ServicesNotFoundError – If nothing was registered for the request.

histogram(
collection,
record_id,
*,
bins=64,
bands=None,
asset=None,
)#

Return the registered histogram; bands is ignored.

Raises:

ServicesNotFoundError – If nothing was registered for the request.

inspect(collection, record_id, *, asset=None)#

Return the registered inspection.

Raises:

ServicesNotFoundError – If nothing was registered for the request.

pixel(collection, record_id, *, x, y, asset=None)#

Return the registered pixel.

Raises:

ServicesNotFoundError – If nothing was registered for the request.

preview(
collection,
record_id,
*,
max_width=1024,
max_height=1024,
bands=None,
stretch='percentile',
max_bytes=16777216,
asset=None,
)#

Return the registered preview; size and band arguments are ignored.

Raises:

ServicesNotFoundError – If nothing was registered for the request, or ServicesProtocolError if it is larger than max_bytes.

product_manifest(
collection,
record_id,
*,
page_size=500,
)#

Return a registered product manifest.

Raises:
  • ValueError – If page_size is not 1 to 500.

  • ServicesNotFoundError – If no manifest was registered for the record.

product_manifest_page(
collection,
record_id,
*,
limit=100,
cursor=None,
)#

Return one page of a registered product manifest.

Raises:
  • ValueError – If limit is not 1 to 500 or cursor is invalid.

  • ServicesNotFoundError – If no manifest was registered for the record.

tile(
collection,
record_id,
*,
z,
x,
y,
bands=None,
stretch='percentile',
max_bytes=16777216,
asset=None,
)#

Return the registered tile; band and stretch arguments are ignored.

Raises:

ServicesNotFoundError – If nothing was registered for the request.

geonemo.client.fakes.FakeServicesClient#

alias of FakeGeoNeMoClient

class geonemo.client.fakes.FakeStatusClient(
*,
status=ProbeState.READY,
service_id='geonemo-services',
services=(),
observations=(),
incidents=(),
now=None,
)#

Configurable read-only fake for health dashboards and consumer checks.

close()#

Do nothing; there is nothing to release.

history(service_id, query=None)#

Return the configured observations of a service, filtered and paged like StatusClient.history.

history_detail(service_id, query=None)#

Return observations of a service with coverage and timeline, like StatusClient.history_detail.

incidents(query=None)#

Return the configured incidents, filtered and paged like StatusClient.incidents.

liveness()#

Return the configured liveness response.

readiness()#

Return the configured readiness response; ready is true only when the fake’s status is ready.

summary(*, window='24h')#

Return the configured summary with window set to the requested one.