Ejemplo n.º 1
0
    def test_add_meta_object(self):
        metadata = Metadata("total_lane_kilometres", region_set, interval_set,
                            "kilometer")
        metadata_set = MetadataSet([])
        metadata_set.add_metadata_object(metadata)

        # access list of metadata attributes
        assert metadata_set.names == ["total_lane_kilometres"]
        assert metadata_set.spatial_resolutions == [region_set]
        assert metadata_set.temporal_resolutions == [interval_set]
        assert metadata_set.units == ["kilometer"]
Ejemplo n.º 2
0
    def test_hanging_inputs(self, get_sector_model):
        """
        sos_model_high
            sos_model_lo
               -> em

        """
        SectorModel = get_sector_model
        energy_model = SectorModel('energy_sector_model')

        input_metadata = {
            'name': 'electricity_demand_input',
            'spatial_resolution': Mock(),
            'temporal_resolution': Mock(),
            'units': 'unit'
        }

        energy_model._model_inputs = MetadataSet([input_metadata])

        sos_model_lo = SosModel('lower')
        sos_model_lo.add_model(energy_model)

        input_object = Metadata(input_metadata['name'],
                                input_metadata['spatial_resolution'],
                                input_metadata['temporal_resolution'],
                                input_metadata['units'])
        expected = MetadataSet([])
        expected.add_metadata_object(input_object)

        assert energy_model.free_inputs.names == ['electricity_demand_input']

        assert sos_model_lo.free_inputs.names == ['electricity_demand_input']

        sos_model_high = SosModel('higher')
        sos_model_high.add_model(sos_model_lo)

        assert sos_model_high.free_inputs['electricity_demand_input'] == \
            input_object