diff --git a/pipeline/fiftyone_pipeline_core/src/fiftyone_pipeline_core/jsonbundler.py b/pipeline/fiftyone_pipeline_core/src/fiftyone_pipeline_core/jsonbundler.py index 408a30d0..dbd5216b 100644 --- a/pipeline/fiftyone_pipeline_core/src/fiftyone_pipeline_core/jsonbundler.py +++ b/pipeline/fiftyone_pipeline_core/src/fiftyone_pipeline_core/jsonbundler.py @@ -125,7 +125,8 @@ def process_internal(self, flowdata): if (flow_element.datakey == "jsonbundler" or flow_element.datakey == "javascriptbuilder" or - flow_element.datakey == "set-headers"): + flow_element.datakey == "set-headers" or + flow_element.datakey == "cloud"): continue properties = flow_element.get_properties() diff --git a/pipeline/fiftyone_pipeline_core/tests/test_jsonbundler_excludes.py b/pipeline/fiftyone_pipeline_core/tests/test_jsonbundler_excludes.py new file mode 100644 index 00000000..204f0b83 --- /dev/null +++ b/pipeline/fiftyone_pipeline_core/tests/test_jsonbundler_excludes.py @@ -0,0 +1,58 @@ +# ********************************************************************* +# This Original Work is copyright of 51 Degrees Mobile Experts Limited. +# Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House, +# Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU. +# +# This Original Work is licensed under the European Union Public Licence +# (EUPL) v.1.2 and is subject to its terms as set out below. +# +# If a copy of the EUPL was not distributed with this file, You can obtain +# one at https://opensource.org/licenses/EUPL-1.2. +# +# The 'Compatible Licences' set out in the Appendix to the EUPL (as may be +# amended by the European Commission) shall be deemed incompatible for +# the purposes of the Work and the provisions of the compatibility +# clause in Article 5 of the EUPL shall not apply. +# +# If using the Work as, or as part of, a network application, by +# including the attribution notice(s) required under Article 5 of the EUPL +# in the end user terms of the application under an appropriate heading, +# such notice(s) shall fulfill the requirements of that article. +# ********************************************************************* + +"""The JSON Builder leaves the Cloud Request Engine's Element Data out of the +JSON, as the JSON Builder specification says.""" + +import unittest + +from fiftyone_pipeline_core.elementdata_dictionary import ElementDataDictionary +from fiftyone_pipeline_core.flowelement import FlowElement +from fiftyone_pipeline_core.pipelinebuilder import PipelineBuilder + + +class StandInCloudRequestEngine(FlowElement): + """Writes the raw answer under the Cloud Request Engine's data key.""" + + def __init__(self): + super(StandInCloudRequestEngine, self).__init__() + self.datakey = "cloud" + self.properties = {"cloud": {"name": "cloud", "type": "string"}} + + def process_internal(self, flowdata): + flowdata.set_element_data(ElementDataDictionary( + self, {"cloud": '{"device":{"ismobile":true}}'})) + + +class JsonBuilderExcludesTests(unittest.TestCase): + + def test_the_cloud_request_engine_is_left_out(self): + pipeline = PipelineBuilder({}).add(StandInCloudRequestEngine()) \ + .build() + self.addCleanup(pipeline.close) + flowdata = pipeline.create_flowdata() + flowdata.process() + self.assertNotIn("cloud", flowdata.jsonbundler.json) + + +if __name__ == "__main__": + unittest.main()