Closed lpapp-foundry closed 1 week ago
A suggested sketch of one way this could be used:
@pytest.fixture
def bal() -> Bal:
return Bal.instance()
def test_when_evaluated_then_location_is_urldecoded_and_path_extracted(read, bal: Bal):
resolved_value = "file:///a/path%20with%20spaces/some.%23%23%23%23.ext"
expected_value = "/a/path with spaces/some.####.ext"
with bal.scoped_entities() as library:
entity = library
.add_entity("aComplexPath")
.locatable_content(resolved_value)
read["file"].setValue(entity.reference)
assert read['file'].getEvaluatedValue() == expected_value
There is a simpler half-way-house to consider, whereby we add some mechanism within BAL to be able to alter its in-memory JSON database at runtime as a JSON document (as opposed to an imperative API).
Riffing off past me... the settings dict could contain a serialised JSON database, as an alternative to a path to a JSON file.
This means the host could get the current state of the database (as serialised JSON) from settings()
. The host could then mutate, re-serialise, and re-initialize(...)
with the updated database.
Pros:
.toml
config file, rather than in a separate file.Cons:
InfoDictionary
is a subset of JSON functionality (e.g no nested objects).${bal_library_dir}
-type variable interpolation.Expanded acceptance criteria based on findings during implementation.
What
Allow users to configure the BAL library using a Python API to simplify the recreation of known states as part of automated testing.
Why
Presently, BAL can only be configured using a JSON library file. This causes several problems with the authoring of automated tests within host integrations:
Notes
Acceptance Criteria
"library_json"
, which contains the serialized database.settings()
and can be set throughinitialize()
${bal_library_dir}
etc, are not provided. If required then they must be passed as any other user-configured"variables"
entry in the library."library_json"
takes precedence over"library_path"
."library_json"
reverts the library to the library stored at"library_path"
, if available.