Ejemplo n.º 1
0
    def test_get_remote_shake_map(self):
        """Check that we can retrieve both input and output from ftp at once.
        """
        shake_event = '20110413170148'
        shake_data = ShakeData(shake_event)

        expected_input_file = os.path.join(shakemap_zip_dir(),
                                           shake_event + '.inp.zip')
        expected_output_file = os.path.join(shakemap_zip_dir(),
                                            shake_event + '.out.zip')

        if os.path.exists(expected_input_file):
            os.remove(expected_input_file)
        if os.path.exists(expected_output_file):
            os.remove(expected_output_file)

        input_file, output_file = shake_data.fetch_event()
        message = ('Expected path for downloaded shakemap INP not received'
                   '\nExpected: %s\nGot: %s' %
                   (expected_output_file, output_file))
        self.assertEqual(input_file, expected_input_file, message)
        message = ('Expected path for downloaded shakemap OUT not received'
                   '\nExpected: %s\nGot: %s' %
                   (expected_output_file, output_file))
        self.assertEqual(output_file, expected_output_file, message)

        assert os.path.exists(expected_input_file)
        assert os.path.exists(expected_output_file)
Ejemplo n.º 2
0
    def test_get_remote_shake_map(self):
        """Check that we can retrieve both input and output from ftp at once"""
        shake_event = '20110413170148'
        shake_data = ShakeData(shake_event)

        expected_input_file = os.path.join(
            shakemap_zip_dir(),
            shake_event + '.inp.zip')
        expected_output_file = os.path.join(
            shakemap_zip_dir(),
            shake_event + '.out.zip')

        if os.path.exists(expected_input_file):
            os.remove(expected_input_file)
        if os.path.exists(expected_output_file):
            os.remove(expected_output_file)

        input_file, output_file = shake_data.fetch_event()
        message = ('Expected path for downloaded shakemap INP not received'
                   '\nExpected: %s\nGot: %s' %
                   (expected_output_file, output_file))
        self.assertEqual(input_file, expected_input_file, message)
        message = ('Expected path for downloaded shakemap OUT not received'
                   '\nExpected: %s\nGot: %s' %
                   (expected_output_file, output_file))
        self.assertEqual(output_file, expected_output_file, message)

        assert os.path.exists(expected_input_file)
        assert os.path.exists(expected_output_file)
Ejemplo n.º 3
0
 def setUp(self):
     """Copy our cached dataset from the fixture dir to the cache dir."""
     output_file = '20120726022003.out.zip'
     input_file = '20120726022003.inp.zip'
     output_path = os.path.abspath(
         os.path.join(os.path.dirname(__file__), '../fixtures',
                      output_file))
     input_path = os.path.abspath(
         os.path.join(os.path.dirname(__file__), '../fixtures', input_file))
     shutil.copyfile(output_path,
                     os.path.join(shakemap_zip_dir(), output_file))
     shutil.copyfile(input_path, os.path.join(shakemap_zip_dir(),
                                              input_file))
Ejemplo n.º 4
0
 def setUp(self):
     """Copy our cached dataset from the fixture dir to the cache dir."""
     output_file = '20120726022003.out.zip'
     input_file = '20120726022003.inp.zip'
     output_path = os.path.abspath(os.path.join(
         os.path.dirname(__file__),
         '../fixtures',
         output_file))
     input_path = os.path.abspath(os.path.join(
         os.path.dirname(__file__),
         '../fixtures',
         input_file))
     shutil.copyfile(output_path,
                     os.path.join(shakemap_zip_dir(), output_file))
     shutil.copyfile(input_path,
                     os.path.join(shakemap_zip_dir(), input_file))
Ejemplo n.º 5
0
 def test_get_shake_map_output(self):
     """Check that we can retrieve a shakemap 'out' input file."""
     event_id = '20110413170148'
     shake_data = ShakeData(event_id)
     shakemap_file = shake_data.fetch_output()
     expected_file = os.path.join(shakemap_zip_dir(), event_id + '.out.zip')
     message = 'Expected path for downloaded shakemap OUT not received'
     self.assertEqual(shakemap_file, expected_file, message)
Ejemplo n.º 6
0
 def test_get_shake_map_output(self):
     """Check that we can retrieve a shakemap 'out' input file"""
     event_id = '20110413170148'
     shake_data = ShakeData(event_id)
     shakemap_file = shake_data.fetch_output()
     expected_file = os.path.join(shakemap_zip_dir(),
                                  event_id + '.out.zip')
     message = 'Expected path for downloaded shakemap OUT not received'
     self.assertEqual(shakemap_file, expected_file, message)
Ejemplo n.º 7
0
 def test_get_shake_map_input(self):
     """Check that we can retrieve a shakemap 'inp' input file"""
     shake_event = '20110413170148'
     shake_data = ShakeData(shake_event)
     shakemap_file = shake_data.fetch_input()
     expected_file = os.path.join(shakemap_zip_dir(),
                                  shake_event + '.inp.zip')
     message = 'Expected path for downloaded shakemap INP not received'
     self.assertEqual(shakemap_file, expected_file, message)
Ejemplo n.º 8
0
 def test_get_latest_shake_map(self):
     """Check that we can retrieve the latest shake event"""
     # Simply dont set the event id in the ctor to get the latest
     shake_data = ShakeData()
     input_file, output_file = shake_data.fetch_event()
     event_id = shake_data.event_id
     expected_input_file = os.path.join(shakemap_zip_dir(),
                                        event_id + '.inp.zip')
     expected_output_file = os.path.join(shakemap_zip_dir(),
                                         event_id + '.out.zip')
     message = ('Expected path for downloaded shakemap INP not received'
                '\nExpected: %s\nGot: %s' %
                (expected_output_file, output_file))
     self.assertEqual(input_file, expected_input_file, message)
     message = ('Expected path for downloaded shakemap OUT not received'
                '\nExpected: %s\nGot: %s' %
                (expected_output_file, output_file))
     self.assertEqual(output_file, expected_output_file, message)
Ejemplo n.º 9
0
    def test_get_cached_shake_map(self):
        """Check that we can retrieve both input and output from ftp at once"""
        shake_event = '20120726022003'

        expected_input_file = os.path.join(shakemap_zip_dir(),
                                           shake_event + '.inp.zip')
        expected_output_file = os.path.join(shakemap_zip_dir(),
                                            shake_event + '.out.zip')
        shake_data = ShakeData(shake_event)
        input_file, output_file = shake_data.fetch_event()
        message = ('Expected path for downloaded shakemap INP not received'
                   '\nExpected: %s\nGot: %s' %
                   (expected_output_file, output_file))
        self.assertEqual(input_file, expected_input_file, message)
        message = ('Expected path for downloaded shakemap OUT not received'
                   '\nExpected: %s\nGot: %s' %
                   (expected_output_file, output_file))
        self.assertEqual(output_file, expected_output_file, message)
Ejemplo n.º 10
0
 def test_get_shake_map_input(self):
     """Check that we can retrieve a shakemap 'inp' input file."""
     shake_event = '20110413170148'
     shake_data = ShakeData(shake_event)
     shakemap_file = shake_data.fetch_input()
     expected_file = os.path.join(shakemap_zip_dir(),
                                  shake_event + '.inp.zip')
     message = 'Expected path for downloaded shakemap INP not received'
     self.assertEqual(shakemap_file, expected_file, message)
Ejemplo n.º 11
0
 def test_get_latest_shake_map(self):
     """Check that we can retrieve the latest shake event."""
     # Simply dont set the event id in the ctor to get the latest
     shake_data = ShakeData()
     input_file, output_file = shake_data.fetch_event()
     event_id = shake_data.event_id
     expected_input_file = os.path.join(shakemap_zip_dir(),
                                        event_id + '.inp.zip')
     expected_output_file = os.path.join(shakemap_zip_dir(),
                                         event_id + '.out.zip')
     message = ('Expected path for downloaded shakemap INP not received'
                '\nExpected: %s\nGot: %s' %
                (expected_output_file, output_file))
     self.assertEqual(input_file, expected_input_file, message)
     message = ('Expected path for downloaded shakemap OUT not received'
                '\nExpected: %s\nGot: %s' %
                (expected_output_file, output_file))
     self.assertEqual(output_file, expected_output_file, message)
Ejemplo n.º 12
0
    def test_get_cached_shake_map(self):
        """Check that we can retrieve both input and output from ftp at once.
        """
        shake_event = '20120726022003'

        expected_input_file = os.path.join(shakemap_zip_dir(),
                                           shake_event + '.inp.zip')
        expected_output_file = os.path.join(shakemap_zip_dir(),
                                            shake_event + '.out.zip')
        shake_data = ShakeData(shake_event)
        input_file, output_file = shake_data.fetch_event()
        message = ('Expected path for downloaded shakemap INP not received'
                   '\nExpected: %s\nGot: %s' %
                   (expected_output_file, output_file))
        self.assertEqual(input_file, expected_input_file, message)
        message = ('Expected path for downloaded shakemap OUT not received'
                   '\nExpected: %s\nGot: %s' %
                   (expected_output_file, output_file))
        self.assertEqual(output_file, expected_output_file, message)
Ejemplo n.º 13
0
 def test_shakemap_zip_dir(self):
     """Test we can get the shakemap zip dir."""
     data_dir = shakemap_zip_dir()
     expected_dir = '/tmp/inasafe/realtime/shakemaps-zipped'
     assert os.path.exists(expected_dir)
     self.assertEqual(data_dir, expected_dir)
Ejemplo n.º 14
0
 def test_shakemap_zip_dir(self):
     """Test we can get the shakemap zip dir."""
     data_dir = shakemap_zip_dir()
     expected_dir = '/tmp/inasafe/realtime/shakemaps-zipped'
     assert os.path.exists(expected_dir)
     self.assertEqual(data_dir, expected_dir)