Exemplo n.º 1
0
    def test_parse(self):
        parser = parsers.SourceModelParser(self.SAMPLE_FILE)

        exp_src_model = self._expected_source_model()
        src_model = parser.parse()

        self.assertTrue(*_utils.deep_eq(exp_src_model, src_model))
Exemplo n.º 2
0
    def test_parse(self):
        parser = parsers.SourceModelParser(self.SAMPLE_FILE)

        exp_src_model = self._expected_source_model()
        src_model = parser.parse()

        self.assertTrue(*_utils.deep_eq(exp_src_model, src_model))
Exemplo n.º 3
0
    def test_parse(self):
        expected_raw = [
            {
                'z2pt5': 5.0,
                'z1pt0': 100.0,
                'vs30': 800.0,
                'wkt': 'POINT(-122.5 37.5)',
                'vs30_type': 'measured'
            },
            {
                'z2pt5': 5.1,
                'z1pt0': 101.0,
                'vs30': 801.0,
                'wkt': 'POINT(-122.6 37.6)',
                'vs30_type': 'measured'
            },
            {
                'z2pt5': 5.2,
                'z1pt0': 102.0,
                'vs30': 802.0,
                'wkt': 'POINT(-122.7 37.7)',
                'vs30_type': 'measured'
            },
            {
                'z2pt5': 5.3,
                'z1pt0': 103.0,
                'vs30': 803.0,
                'wkt': 'POINT(-122.8 37.8)',
                'vs30_type': 'measured'
            },
            {
                'z2pt5': 5.4,
                'z1pt0': 104.0,
                'vs30': 804.0,
                'wkt': 'POINT(-122.9 37.9)',
                'vs30_type': 'measured'
            },
        ]
        expected = [models.SiteModel(**x) for x in expected_raw]

        parser = parsers.SiteModelParser(self.SAMPLE_FILE)
        actual = [x for x in parser.parse()]

        self.assertTrue(*_utils.deep_eq(expected, actual))
Exemplo n.º 4
0
    def test_parse(self):
        expected_raw = [
            {'z2pt5': 5.0, 'z1pt0': 100.0, 'vs30': 800.0,
             'wkt': 'POINT(-122.5 37.5)', 'vs30_type': 'measured'},
            {'z2pt5': 5.1, 'z1pt0': 101.0, 'vs30': 801.0,
             'wkt': 'POINT(-122.6 37.6)', 'vs30_type': 'measured'},
            {'z2pt5': 5.2, 'z1pt0': 102.0, 'vs30': 802.0,
             'wkt': 'POINT(-122.7 37.7)', 'vs30_type': 'measured'},
            {'z2pt5': 5.3, 'z1pt0': 103.0, 'vs30': 803.0,
             'wkt': 'POINT(-122.8 37.8)', 'vs30_type': 'measured'},
            {'z2pt5': 5.4, 'z1pt0': 104.0, 'vs30': 804.0,
             'wkt': 'POINT(-122.9 37.9)', 'vs30_type': 'measured'},
        ]
        expected = [models.SiteModel(**x) for x in expected_raw]

        parser = parsers.SiteModelParser(self.SAMPLE_FILE)
        actual = [x for x in parser.parse()]

        self.assertTrue(*_utils.deep_eq(expected, actual))
Exemplo n.º 5
0
    def test_geojson_parsing(self):
        # Test geojson parsing by comparing the
        # parsed values from the xml and geojson parsers.
        # The xml parser is already well tested, so this should
        # be sufficient.
        example_xml = [
            'examples/hazard-curves-pga.xml',
            'examples/hazard-curves-sa.xml',
            'examples/hazard-curves-quantile.xml',
            'examples/hazard-curves-mean.xml',
        ]
        example_geojson = [
            'examples/hazard-curves-pga.geojson',
            'examples/hazard-curves-sa.geojson',
            'examples/hazard-curves-quantile.geojson',
            'examples/hazard-curves-mean.geojson',
        ]
        for xml, geo in zip(example_xml, example_geojson):
            xp = parsers.HazardCurveXMLParser(xml)
            gp = parsers.HazardCurveGeoJSONParser(geo)

            equal, err = _utils.deep_eq(xp.parse(), gp.parse())
            self.assertTrue(equal, err)
Exemplo n.º 6
0
    def test_geojson_parsing(self):
        # Test geojson parsing by comparing the
        # parsed values from the xml and geojson parsers.
        # The xml parser is already well tested, so this should
        # be sufficient.
        example_xml = [
            'examples/hazard-curves-pga.xml',
            'examples/hazard-curves-sa.xml',
            'examples/hazard-curves-quantile.xml',
            'examples/hazard-curves-mean.xml',
        ]
        example_geojson = [
            'examples/hazard-curves-pga.geojson',
            'examples/hazard-curves-sa.geojson',
            'examples/hazard-curves-quantile.geojson',
            'examples/hazard-curves-mean.geojson',
        ]
        for xml, geo in zip(example_xml, example_geojson):
            xp = parsers.HazardCurveXMLParser(xml)
            gp = parsers.HazardCurveGeoJSONParser(geo)

            equal, err = _utils.deep_eq(xp.parse(), gp.parse())
            self.assertTrue(equal, err)
Exemplo n.º 7
0
 def test_parse(self):
     for curve, expected in self.EXPECTED.iteritems():
         parser = parsers.HazardCurveXMLParser(curve)
         model = parser.parse()
         equal, err = _utils.deep_eq(expected, model)
         self.assertTrue(equal, err)
Exemplo n.º 8
0
 def test_parse(self):
     for fname, expected_model in zip(
             self.SAMPLE_FILES, self.EXPECTED_MODELS):
         parser = parsers.RuptureModelParser(fname)
         model = parser.parse()
         self.assertTrue(*_utils.deep_eq(model, expected_model))
Exemplo n.º 9
0
 def test_parse(self):
     for curve, expected in self.EXPECTED.iteritems():
         parser = parsers.HazardCurveXMLParser(curve)
         model = parser.parse()
         equal, err = _utils.deep_eq(expected, model)
         self.assertTrue(equal, err)
Exemplo n.º 10
0
 def test_parse(self):
     for fname, expected_model in zip(self.SAMPLE_FILES,
                                      self.EXPECTED_MODELS):
         parser = parsers.RuptureModelParser(fname)
         model = parser.parse()
         self.assertTrue(*_utils.deep_eq(model, expected_model))