def test_not_nrml(self): content = '''<html><head></head><body></body></html>''' xml_file = StringIO.StringIO(content) with self.assertRaises(AssertionError) as ar: views._is_source_model(xml_file) self.assertEqual('Input file is not a NRML artifact', ar.exception.message)
def test_true(self): content = '''<?xml version='1.0' encoding='utf-8'?> <nrml xmlns:gml="http://www.opengis.net/gml" xmlns="http://openquake.org/xmlns/nrml/0.4"> <sourceModel name="Some Source Model"> <pointSource id="1" name="point" tectonicRegion="Stable Continental Crust"> <pointGeometry> <gml:Point> <gml:pos>-122.0 38.0</gml:pos> </gml:Point> <upperSeismoDepth>0.0</upperSeismoDepth> <lowerSeismoDepth>10.0</lowerSeismoDepth> </pointGeometry> <magScaleRel>WC1994</magScaleRel> <ruptAspectRatio>0.5</ruptAspectRatio> <truncGutenbergRichterMFD aValue="-3.5" bValue="1.0" minMag="5.0" maxMag="6.5" /> <nodalPlaneDist> <nodalPlane probability="0.3" strike="0.0" dip="90.0" rake="0.0" /> <nodalPlane probability="0.7" strike="90.0" dip="45.0" rake="90.0" /> </nodalPlaneDist> <hypoDepthDist> <hypoDepth probability="0.5" depth="4.0" /> <hypoDepth probability="0.5" depth="8.0" /> </hypoDepthDist> </pointSource> </sourceModel> </nrml> ''' xml_file = StringIO.StringIO(content) self.assertTrue(views._is_source_model(xml_file))
def test_false(self): content = '''<?xml version='1.0' encoding='utf-8'?> <nrml xmlns:gml="http://www.opengis.net/gml" xmlns="http://openquake.org/xmlns/nrml/0.4"> <pointRupture> <magnitude type="Mw">6.5</magnitude> <strike>20.0</strike> <dip>90.0</dip> <rake>10.0</rake> <hypocenterLocation> <gml:Point srsName="urn:ogc:def:crs:EPSG::4979"> <gml:pos>-124.704 40.363 30.0</gml:pos> </gml:Point> </hypocenterLocation> </pointRupture> </nrml> ''' xml_file = StringIO.StringIO(content) self.assertFalse(views._is_source_model(xml_file))