Ejemplo n.º 1
0
    def test_from_json(self):
        json_path = fixtures.get("test_probe.json")
        with open(json_path) as f:
            data = json.load(f)
        layer_data = {"data_sources": data["workflow"]["execution_layers"][0]}
        layer = ExecutionLayer.from_json(self.registry, layer_data)

        self.assertDictEqual(
            layer_data["data_sources"][0],
            {
                "id": "force.bdss.enthought.plugin.test.v0."
                "factory.probe_data_source",
                "model_data": {
                    "input_slot_info": [{
                        "source": "Environment",
                        "name": "foo"
                    }],
                    "output_slot_info": [{
                        "name": "bar"
                    }],
                },
            },
        )

        layer_data["data_sources"][0]["model_data"].update({
            "input_slots_type":
            "PRESSURE",
            "output_slots_type":
            "PRESSURE",
            "input_slots_size":
            1,
            "output_slots_size":
            1,
        })
        self.assertDictEqual(layer.__getstate__(), layer_data)
Ejemplo n.º 2
0
    def _extract_execution_layers(factory_registry, workflow_data):
        """ Generates the List(ExecutionLayer) from the `workflow_data` dictionary.

        Parameters
        ----------
        factory_registry: IFactoryRegistry
            Generating factory registry for the data sources inside the
            execution layers
        workflow_data: dict
            Dictionary with the content of the `ExecutionLayer`s in
            serialized format

        Returns
        -------
        execution_layers: List(ExecutionLayer)
            list of ExecutionLayer instances.
        """
        execution_layers = []
        for layer_data in workflow_data["execution_layers"]:
            layer = ExecutionLayer.from_json(factory_registry, layer_data)
            execution_layers.append(layer)

        return execution_layers
Ejemplo n.º 3
0
 def test_empty_layer_from_json(self):
     layer = ExecutionLayer.from_json(self.registry, {})
     self.assertEqual(0, len(layer.data_sources))