fixed bug in check for empty data in refactored aggregation strategy... was correct before
This commit is contained in:
parent
0d455422b7
commit
3a6e9281ce
@ -32,7 +32,7 @@ class AggregationStorageStrategy(ResponseStrategy):
|
||||
|
||||
self.add_analysis_payload_to_buffer(analysis_payload)
|
||||
|
||||
if not analysis_payload["data"] or last:
|
||||
if analysis_payload["data"] or last:
|
||||
self.upload_aggregated_items(object_descriptor)
|
||||
# TODO: mappings such as object_name -> responseFile should be put in a separate interface mapping layer.
|
||||
# See the enum-formatter in image-prediction service for reference.
|
||||
@ -40,6 +40,8 @@ class AggregationStorageStrategy(ResponseStrategy):
|
||||
else:
|
||||
return Nothing
|
||||
|
||||
# TODO: aggregate response files and make responseFile -> responseFiles
|
||||
|
||||
def add_analysis_payload_to_buffer(self, analysis_payload):
|
||||
self.buffer.append({**analysis_payload, "metadata": omit(analysis_payload["metadata"], ["id"])})
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
from pyinfra.visitor.strategies.response.aggregation import AggregationStorageStrategy
|
||||
@ -19,15 +21,23 @@ class TestAggregationStorageStrategy:
|
||||
}
|
||||
response_message_bodies = [*strat(analysis_response)]
|
||||
assert response_message_bodies == [
|
||||
{
|
||||
"dossierId": "dossier0",
|
||||
"fileId": "file0",
|
||||
"pages": [0, 2],
|
||||
"id": 1,
|
||||
"responseFile": "dossier0/file0/id:1.json.gz",
|
||||
},
|
||||
{
|
||||
"dossierId": "dossier0",
|
||||
"fileId": "file0",
|
||||
"pages": [0, 2],
|
||||
"id": 3,
|
||||
"responseFile": "dossier0/file0/id:3.json.gz",
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def test_aggregation_strategy_with_empty_data_field(self, storage):
|
||||
strat = AggregationStorageStrategy(storage=storage)
|
||||
|
||||
@ -42,13 +52,6 @@ class TestAggregationStorageStrategy:
|
||||
}
|
||||
response_message_bodies = [*strat(analysis_response)]
|
||||
assert response_message_bodies == [
|
||||
{
|
||||
"dossierId": "dossier0",
|
||||
"fileId": "file0",
|
||||
"pages": [0, 2],
|
||||
"id": 1,
|
||||
"responseFile": "dossier0/file0/id:1.json.gz",
|
||||
},
|
||||
{
|
||||
"dossierId": "dossier0",
|
||||
"fileId": "file0",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user