def setUp(self):

        self.trace_fst_fault = [(90.563202328, 24.926468434),
            (90.510844525, 23.892401812), (90.615560132, 22.400204407),
            (90.995154209, 21.287601079)]

        self.trace_snd_fault = [(90.995154209, 21.287601079),
            (92.294781845, 19.714732881), (93.262975563, 18.352958814),
            (93.581460339, 17.816563619)]

        self.fst_fault = SimpleFaultGeo(self.trace_fst_fault, 4.0, 35.0, 5.0)

        self.snd_fault = SimpleFaultGeo(self.trace_snd_fault, 0.0, 35.0, 10.0)
    def setUp(self):

        self.trace_fst_fault = [(90.563202328, 24.926468434),
                                (90.510844525, 23.892401812),
                                (90.615560132, 22.400204407),
                                (90.995154209, 21.287601079)]

        self.trace_snd_fault = [(90.995154209, 21.287601079),
                                (92.294781845, 19.714732881),
                                (93.262975563, 18.352958814),
                                (93.581460339, 17.816563619)]

        self.fst_fault = SimpleFaultGeo(self.trace_fst_fault, 4.0, 35.0, 5.0)

        self.snd_fault = SimpleFaultGeo(self.trace_snd_fault, 0.0, 35.0, 10.0)
 def _input_args(self):
     return {
         'slip':
         20.0,
         'aseismic_coef':
         0.0,
         'b_value':
         0.8,
         'min_mag':
         5.0,
         'bin_width':
         0.1,
         'max_mag':
         8.5,
         'tectonic_region':
         TectonicRegionBuilder.create_tect_region_by_name(
             TectonicRegionBuilder.ACTIVE_SHALLOW_CRUST,
             smod={
                 'value': [27.70],
                 'weight': [1.0]
             }),
         'sf_geo':
         SimpleFaultGeo([(90.5632, 24.9265), (90.5108, 23.8924),
                         (90.6156, 22.4002), (90.9952, 21.2876)], 4.00,
                        35.0, 5.0)
     }
class SimpleFaultGeoShould(unittest.TestCase):

    def setUp(self):

        self.trace_fst_fault = [(90.563202328, 24.926468434),
            (90.510844525, 23.892401812), (90.615560132, 22.400204407),
            (90.995154209, 21.287601079)]

        self.trace_snd_fault = [(90.995154209, 21.287601079),
            (92.294781845, 19.714732881), (93.262975563, 18.352958814),
            (93.581460339, 17.816563619)]

        self.fst_fault = SimpleFaultGeo(self.trace_fst_fault, 4.0, 35.0, 5.0)

        self.snd_fault = SimpleFaultGeo(self.trace_snd_fault, 0.0, 35.0, 10.0)

    def test_provide_length(self):
        self.assertAlmostEqual(411.14582,
            self.fst_fault.get_length(), places=5)
        self.assertAlmostEqual(472.08545,
            self.snd_fault.get_length(), places=5)

    def test_provide_width(self):
        self.assertAlmostEqual(355.68511,
            self.fst_fault.get_width(), places=5)
        self.assertAlmostEqual(201.55697,
            self.snd_fault.get_width(), places=5)

    def test_provide_area(self):
        self.assertAlmostEqual(146238.4464,
            self.fst_fault.get_area(), places=4)
        self.assertAlmostEqual(95152.1118,
            self.snd_fault.get_area(), places=4)

    def test_raises_value_error_invalid_params(self):
        # Trace with one point
        self.assertRaises(ValueError, SimpleFaultGeo, [(90, 24)],
            4.0, 35.0, 5.0)

        # Trace with invalid longitude value
        self.assertRaises(ValueError, SimpleFaultGeo, [(-185, 54), (90, 23)],
            4.0, 35.0, 5.0)

        # Trace with invalid latitude value
        self.assertRaises(ValueError, SimpleFaultGeo, [(90, -25), (90, 91)],
            4.0, 35.0, 5.0)

        # Negative upper depth
        self.assertRaises(ValueError, SimpleFaultGeo, [(90, 24), (90, 21)],
            -1, 35.0, 5.0)

        # Non greater than zero lower depth
        self.assertRaises(ValueError, SimpleFaultGeo, [(90, 24), (90, 21)],
            1, 0, 5.0)

        # Lower depth not greater than upper depth
        self.assertRaises(ValueError, SimpleFaultGeo, [(90, 24), (90, 21)],
            3, 2, 5.0)

        # Invalid dip
        self.assertRaises(ValueError, SimpleFaultGeo, [(90, 24), (90, 21)],
            2, 3, 95)
class SimpleFaultGeoShould(unittest.TestCase):
    def setUp(self):

        self.trace_fst_fault = [(90.563202328, 24.926468434),
                                (90.510844525, 23.892401812),
                                (90.615560132, 22.400204407),
                                (90.995154209, 21.287601079)]

        self.trace_snd_fault = [(90.995154209, 21.287601079),
                                (92.294781845, 19.714732881),
                                (93.262975563, 18.352958814),
                                (93.581460339, 17.816563619)]

        self.fst_fault = SimpleFaultGeo(self.trace_fst_fault, 4.0, 35.0, 5.0)

        self.snd_fault = SimpleFaultGeo(self.trace_snd_fault, 0.0, 35.0, 10.0)

    def test_provide_length(self):
        self.assertAlmostEqual(411.14582,
                               self.fst_fault.get_length(),
                               places=5)
        self.assertAlmostEqual(472.08545,
                               self.snd_fault.get_length(),
                               places=5)

    def test_provide_width(self):
        self.assertAlmostEqual(355.68511, self.fst_fault.get_width(), places=5)
        self.assertAlmostEqual(201.55697, self.snd_fault.get_width(), places=5)

    def test_provide_area(self):
        self.assertAlmostEqual(146238.4464,
                               self.fst_fault.get_area(),
                               places=4)
        self.assertAlmostEqual(95152.1118, self.snd_fault.get_area(), places=4)

    def test_raises_value_error_invalid_params(self):
        # Trace with one point
        self.assertRaises(ValueError, SimpleFaultGeo, [(90, 24)], 4.0, 35.0,
                          5.0)

        # Trace with invalid longitude value
        self.assertRaises(ValueError, SimpleFaultGeo, [(-185, 54), (90, 23)],
                          4.0, 35.0, 5.0)

        # Trace with invalid latitude value
        self.assertRaises(ValueError, SimpleFaultGeo, [(90, -25), (90, 91)],
                          4.0, 35.0, 5.0)

        # Negative upper depth
        self.assertRaises(ValueError, SimpleFaultGeo, [(90, 24), (90, 21)], -1,
                          35.0, 5.0)

        # Non greater than zero lower depth
        self.assertRaises(ValueError, SimpleFaultGeo, [(90, 24), (90, 21)], 1,
                          0, 5.0)

        # Lower depth not greater than upper depth
        self.assertRaises(ValueError, SimpleFaultGeo, [(90, 24), (90, 21)], 3,
                          2, 5.0)

        # Invalid dip
        self.assertRaises(ValueError, SimpleFaultGeo, [(90, 24), (90, 21)], 2,
                          3, 95)