STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_config_checkout Namespace Reference

Functions

 probe_header (None _=DesignCheckout)
 probe_query (None _=DesignCheckout)
 _isolate (tmp_path, monkeypatch)
 client ()
 _create (client, headers, name="Baseline")
 _take (client, doc_id, headers, params=None)
 _release (client, doc_id, headers, params=None)
 test_no_design_named_is_allowed (client)
 test_holder_may_write (client)
 test_write_without_the_checkout_is_refused (client)
 test_write_while_someone_else_holds_it_is_refused (client)
 test_query_params_work_too (client)
 test_unknown_design_is_allowed (client)
 test_a_lapsed_checkout_nobody_took_is_reclaimed_by_a_config_write (client, monkeypatch)
 test_a_lapsed_checkout_someone_else_took_is_refused (client, monkeypatch)

Variables

 reason
dict A = {"X-Auth-Email": "alice@berkeley.edu"}
dict B = {"X-Auth-Email": "bob@berkeley.edu"}
str BASE = "/api/engine/documents"
 app = FastAPI()

Detailed Description

The live-config routes refuse a write from someone who does not hold the design.

The checkout already gated /api/engine/documents/{id}/autosave, which protects
the *stored* design. It did not gate /api/config, which is what the UI actually
edits -- so a read-only viewer's changes landed in their own session, the screen
updated, and the edit then evaporated at the next reload with nothing said.
These tests pin the refusal at the point of the edit.

See backend/checkout.py for why /api/config/load is deliberately NOT gated: it
is how the design bar opens a design you may only view.

Function Documentation

◆ _create()

◆ _isolate()

test_config_checkout._isolate ( tmp_path,
monkeypatch )
protected

Definition at line 52 of file test_config_checkout.py.

◆ _release()

test_config_checkout._release ( client,
doc_id,
headers,
params = None )
protected

◆ _take()

◆ client()

test_config_checkout.client ( )

Definition at line 58 of file test_config_checkout.py.

◆ probe_header()

test_config_checkout.probe_header ( None _ = DesignCheckout)

Definition at line 42 of file test_config_checkout.py.

◆ probe_query()

test_config_checkout.probe_query ( None _ = DesignCheckout)

Definition at line 47 of file test_config_checkout.py.

◆ test_a_lapsed_checkout_nobody_took_is_reclaimed_by_a_config_write()

test_config_checkout.test_a_lapsed_checkout_nobody_took_is_reclaimed_by_a_config_write ( client,
monkeypatch )
The config edit that arrives after a lapse is kept, not refused, when
nobody has taken the design since -- the same rule as the design's own
autosave (`DesignStore.claim_for_write`).

Definition at line 133 of file test_config_checkout.py.

References _create(), and _take().

◆ test_a_lapsed_checkout_someone_else_took_is_refused()

test_config_checkout.test_a_lapsed_checkout_someone_else_took_is_refused ( client,
monkeypatch )

Definition at line 144 of file test_config_checkout.py.

References _create(), and _take().

◆ test_holder_may_write()

test_config_checkout.test_holder_may_write ( client)

Definition at line 84 of file test_config_checkout.py.

References _create(), and _take().

◆ test_no_design_named_is_allowed()

test_config_checkout.test_no_design_named_is_allowed ( client)
The config routes predate designs; scripted and file-upload callers still
use them with nothing open, and must keep working.

Definition at line 78 of file test_config_checkout.py.

◆ test_query_params_work_too()

test_config_checkout.test_query_params_work_too ( client)
The optimizer layers stream over EventSource, which cannot set headers.

Definition at line 116 of file test_config_checkout.py.

References _create(), _release(), and _take().

◆ test_unknown_design_is_allowed()

test_config_checkout.test_unknown_design_is_allowed ( client)
A stale id in localStorage must not brick every config write.

Definition at line 127 of file test_config_checkout.py.

◆ test_write_while_someone_else_holds_it_is_refused()

test_config_checkout.test_write_while_someone_else_holds_it_is_refused ( client)

Definition at line 101 of file test_config_checkout.py.

References _create(), and _take().

◆ test_write_without_the_checkout_is_refused()

test_config_checkout.test_write_without_the_checkout_is_refused ( client)
Creating a design checks it out to you, so release it first: this is the
'my checkout lapsed and I kept typing' case.

Definition at line 91 of file test_config_checkout.py.

References _create(), and _release().

Variable Documentation

◆ A

dict test_config_checkout.A = {"X-Auth-Email": "alice@berkeley.edu"}

Definition at line 29 of file test_config_checkout.py.

◆ app

test_config_checkout.app = FastAPI()

Definition at line 37 of file test_config_checkout.py.

◆ B

dict test_config_checkout.B = {"X-Auth-Email": "bob@berkeley.edu"}

Definition at line 30 of file test_config_checkout.py.

◆ BASE

str test_config_checkout.BASE = "/api/engine/documents"

Definition at line 31 of file test_config_checkout.py.

◆ reason

test_config_checkout.reason

Definition at line 20 of file test_config_checkout.py.