def test_serialize_quantile_geojson(self):
        expected = {
            'type': 'FeatureCollection',
            'oqnrmlversion': '0.4',
            'oqtype': 'HazardMap',
            'oqmetadata': {
                'statistics': 'quantile',
                'quantileValue': '0.85',
                'IMT': 'SA',
                'saPeriod': '0.025',
                'saDamping': '5.0',
                'investigationTime': '50.0',
                'poE': '0.1',
            },
            'features': [
                {'type': 'Feature',
                 'geometry': {'type': 'Point', 'coordinates': [-1.0, 1.0]},
                 'properties': {'iml': 0.01},
                 },
                {'type': 'Feature',
                 'geometry': {'type': 'Point', 'coordinates': [1.0, 1.0]},
                 'properties': {'iml': 0.02},
                 },
                {'type': 'Feature',
                 'geometry': {'type': 'Point', 'coordinates': [1.0, -1.0]},
                 'properties': {'iml': 0.03},
                 },
                {'type': 'Feature',
                 'geometry': {'type': 'Point', 'coordinates': [-1.0, -1.0]},
                 'properties': {'iml': 0.04},
                 },
            ],
        }

        metadata = dict(
            investigation_time=50.0, imt='SA', poe=0.1, sa_period=0.025,
            sa_damping=5.0, statistics='quantile', quantile_value=0.85
        )
        writer = writers.HazardMapGeoJSONWriter(path, **metadata)
        writer.serialize(self.data)

        actual = json.load(open(path))
        self.assertEqual(expected, actual)
    def test_serialize_geojson(self):
        expected = {
            'type':
            'FeatureCollection',
            'oqnrmlversion':
            '0.4',
            'oqtype':
            'HazardMap',
            'oqmetadata': {
                'sourceModelTreePath': 'b1_b2_b4',
                'gsimTreePath': 'b1_b4_b5',
                'IMT': 'SA',
                'saPeriod': '0.025',
                'saDamping': '5.0',
                'investigationTime': '50.0',
                'poE': '0.1',
            },
            'features': [
                {
                    'type': 'Feature',
                    'geometry': {
                        'type': 'Point',
                        'coordinates': [-1.0, 1.0]
                    },
                    'properties': {
                        'iml': 0.01
                    },
                },
                {
                    'type': 'Feature',
                    'geometry': {
                        'type': 'Point',
                        'coordinates': [1.0, 1.0]
                    },
                    'properties': {
                        'iml': 0.02
                    },
                },
                {
                    'type': 'Feature',
                    'geometry': {
                        'type': 'Point',
                        'coordinates': [1.0, -1.0]
                    },
                    'properties': {
                        'iml': 0.03
                    },
                },
                {
                    'type': 'Feature',
                    'geometry': {
                        'type': 'Point',
                        'coordinates': [-1.0, -1.0]
                    },
                    'properties': {
                        'iml': 0.04
                    },
                },
            ],
        }

        metadata = dict(investigation_time=50.0,
                        imt='SA',
                        poe=0.1,
                        sa_period=0.025,
                        sa_damping=5.0,
                        smlt_path='b1_b2_b4',
                        gsimlt_path='b1_b4_b5')
        writer = writers.HazardMapGeoJSONWriter(self.path, **metadata)
        writer.serialize(self.data)

        actual = json.load(open(self.path))
        self.assertEqual(expected, actual)