예제 #1
0
    def test_get_temporal_property(self, two_output_metrics, interval_set):
        """Access different temporal resolutions for different metadata
        """
        outputs = MetadataSet(two_output_metrics)
        assert outputs.get_temporal_res('total_cost') == interval_set
        assert outputs.get_temporal_res('water_demand') == interval_set

        with raises(KeyError) as ex:
            outputs.get_temporal_res('missing')
        assert "No metadata found for name 'missing'" in str(ex.value)
예제 #2
0
    def test_create_metadata_set(self, interval_set, region_set):
        """Create MetadataSet to hold a list of Metadata
        """
        metadata_list = [{
            "name": "heat_demand",
            "spatial_resolution": region_set,
            "temporal_resolution": interval_set,
            "units": "kilowatt"
        }]
        metadata_set = MetadataSet(metadata_list)

        # direct access to single metadata
        metadata = metadata_set["heat_demand"]
        assert metadata.name == "heat_demand"
        assert metadata.spatial_resolution == region_set
        assert metadata.temporal_resolution == interval_set
        assert metadata.units == "kilowatt"

        # direct access to list of contained metadata
        assert len(metadata_set) == 1
        assert metadata_set.metadata == [
            Metadata("heat_demand", region_set, interval_set, "kilowatt")
        ]

        # access single metadata attribute
        assert metadata_set.get_spatial_res("heat_demand") == region_set
        assert metadata_set.get_temporal_res("heat_demand") == interval_set
        assert metadata_set.get_units("heat_demand") == "kilowatt"

        # access list of metadata attributes
        assert metadata_set.names == ["heat_demand"]
        assert metadata_set.spatial_resolutions == [region_set]
        assert metadata_set.temporal_resolutions == [interval_set]
        assert metadata_set.units == ["kilowatt"]