Skip to content

Commit

Permalink
[Core] Use TraitsData in preflight
Browse files Browse the repository at this point in the history
Part of OpenAssetIO/OpenAssetIO#1028. The API signature of `preflight`
has changed to take a list of `TraitsData` objects, rather than a single
trait set.

No actual behaviour change required.

Update business logic tests to reflect new API signature.

Update API compliance test suite fixtures to refactored form for the new
signature.

Signed-off-by: David Feltell <[email protected]>
  • Loading branch information
feltech committed Aug 10, 2023
1 parent 81befa5 commit 50432f2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def resolve(

@simulated_delay
def preflight(
self, targetEntityRefs, traitSet, context, hostSession, successCallback, errorCallback
self, targetEntityRefs, traitsDatas, context, hostSession, successCallback, errorCallback
):
# Support publishing to any valid entity reference
for idx, ref in enumerate(targetEntityRefs):
Expand Down
4 changes: 2 additions & 2 deletions tests/bal_business_logic_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,14 @@ def test_when_refs_valid_then_are_passed_through_unchanged(self):
self._manager.createEntityReference(s)
for s in ["bal:///A ref to a 🐔", "bal:///anotherRef"]
]
trait_set = {"a_trait", "another_trait"}
traits_datas = [TraitsData()] * len(entity_references)
context = self.createTestContext(access=Context.Access.kWrite)

result_references = [None] * len(entity_references)

self._manager.preflight(
entity_references,
trait_set,
traits_datas,
context,
lambda idx, ref: operator.setitem(result_references, idx, ref),
lambda _idx, _err: self.fail("Preflight should not error for this input"),
Expand Down
6 changes: 4 additions & 2 deletions tests/bal_functional_behaviour_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ def test_when_resolve_called_then_results_delayed_by_specified_simulated_query_l
)

def test_when_preflight_called_then_results_delayed_by_specified_simulated_query_latency(self):
entity_references = self.create_test_entity_references()
traits_datas = [TraitsData({"string"})] * len(entity_references)
self.__check_simulated_latencies_with_callbacks(
self._manager.preflight,
self.create_test_entity_references(),
{"string"},
entity_references,
traits_datas,
self.createTestContext(access=Context.Access.kRead),
)

Expand Down
26 changes: 21 additions & 5 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,27 @@
}
},
"Test_preflight": {
"shared": {
"a_reference_to_a_writable_entity": "bal:///someNewEntity",
"a_set_of_valid_traits": some_registerable_traitset,
"the_error_string_for_a_malformed_reference": ERROR_MSG_MALFORMED_REF,
}
"test_when_multiple_references_then_same_number_of_returned_references": {
"a_traits_data_for_preflight": TraitsData({"anything"}),
"a_reference_for_preflight": "bal:///someNewEntity",
},
"test_when_reference_is_read_only_then_access_error_is_returned": {
# Skipped: all BAL entities can be published to.
# "a_traits_data_for_preflight":
# "a_reference_to_a_readonly_entity":,
# "expected_error_message":
},
"test_when_reference_malformed_then_malformed_entity_reference_error_returned": {
"a_traits_data_for_preflight": TraitsData({"anything"}),
"a_malformed_reference": MALFORMED_REF,
"expected_error_message": ERROR_MSG_MALFORMED_REF,
},
"test_when_preflight_hint_invalid_then_invalid_preflight_hint_error_returned": {
# Skipped: all BAL entities can be published to.
# "an_invalid_traits_data_for_preflight":
# "a_reference_for_preflight":,
# "expected_error_message":
},
},
"Test_register": {
"shared": {
Expand Down

0 comments on commit 50432f2

Please sign in to comment.