Пример #1
0
    def testGetRemoteShakeMap(self):
        """Check that we can retrieve both input and output from ftp at once"""
        myShakeEvent = '20110413170148'
        myShakeData = ShakeData(myShakeEvent)

        myExpectedInpFile = os.path.join(shakemapZipDir(),
                                         myShakeEvent + '.inp.zip')
        myExpectedOutFile = os.path.join(shakemapZipDir(),
                                         myShakeEvent + '.out.zip')

        if os.path.exists(myExpectedInpFile):
            os.remove(myExpectedInpFile)
        if os.path.exists(myExpectedOutFile):
            os.remove(myExpectedOutFile)

        myInpFile, myOutFile = myShakeData.fetchEvent()
        myMessage = ('Expected path for downloaded shakemap INP not received'
             '\nExpected: %s\nGot: %s' %
             (myExpectedOutFile, myOutFile))
        self.assertEqual(myInpFile, myExpectedInpFile, myMessage)
        myMessage = ('Expected path for downloaded shakemap OUT not received'
             '\nExpected: %s\nGot: %s' %
             (myExpectedOutFile, myOutFile))
        self.assertEqual(myOutFile, myExpectedOutFile, myMessage)

        assert os.path.exists(myExpectedInpFile)
        assert os.path.exists(myExpectedOutFile)
Пример #2
0
    def testGetRemoteShakeMap(self):
        """Check that we can retrieve both input and output from ftp at once"""
        myShakeEvent = '20110413170148'
        myShakeData = ShakeData(myShakeEvent)

        myExpectedInpFile = os.path.join(shakemapZipDir(),
                                         myShakeEvent + '.inp.zip')
        myExpectedOutFile = os.path.join(shakemapZipDir(),
                                         myShakeEvent + '.out.zip')

        if os.path.exists(myExpectedInpFile):
            os.remove(myExpectedInpFile)
        if os.path.exists(myExpectedOutFile):
            os.remove(myExpectedOutFile)

        myInpFile, myOutFile = myShakeData.fetchEvent()
        myMessage = ('Expected path for downloaded shakemap INP not received'
                     '\nExpected: %s\nGot: %s' %
                     (myExpectedOutFile, myOutFile))
        self.assertEqual(myInpFile, myExpectedInpFile, myMessage)
        myMessage = ('Expected path for downloaded shakemap OUT not received'
                     '\nExpected: %s\nGot: %s' %
                     (myExpectedOutFile, myOutFile))
        self.assertEqual(myOutFile, myExpectedOutFile, myMessage)

        assert os.path.exists(myExpectedInpFile)
        assert os.path.exists(myExpectedOutFile)
Пример #3
0
 def setUp(self):
     """Copy our cached dataset from the fixture dir to the cache dir"""
     myOutFile = '20120726022003.out.zip'
     myInpFile = '20120726022003.inp.zip'
     myOutPath = os.path.abspath(
         os.path.join(os.path.dirname(__file__), '../fixtures', myOutFile))
     myInpPath = os.path.abspath(
         os.path.join(os.path.dirname(__file__), '../fixtures', myInpFile))
     shutil.copyfile(myOutPath, os.path.join(shakemapZipDir(), myOutFile))
     shutil.copyfile(myInpPath, os.path.join(shakemapZipDir(), myInpFile))
Пример #4
0
 def setUp(self):
     """Copy our cached dataset from the fixture dir to the cache dir"""
     myOutFile = '20120726022003.out.zip'
     myInpFile = '20120726022003.inp.zip'
     myOutPath = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                              '../fixtures',
                                              myOutFile))
     myInpPath = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                              '../fixtures',
                                              myInpFile))
     shutil.copyfile(myOutPath, os.path.join(shakemapZipDir(), myOutFile))
     shutil.copyfile(myInpPath, os.path.join(shakemapZipDir(), myInpFile))
Пример #5
0
 def testGetShakeMapOutput(self):
     """Check that we can retrieve a shakemap 'out' input file"""
     myEventId = '20110413170148'
     myShakeData = ShakeData(myEventId)
     myShakemapFile = myShakeData.fetchOutput()
     myExpectedFile = os.path.join(shakemapZipDir(), myEventId + '.out.zip')
     myMessage = 'Expected path for downloaded shakemap OUT not received'
     self.assertEqual(myShakemapFile, myExpectedFile, myMessage)
Пример #6
0
 def testGetShakeMapOutput(self):
     """Check that we can retrieve a shakemap 'out' input file"""
     myEventId = '20110413170148'
     myShakeData = ShakeData(myEventId)
     myShakemapFile = myShakeData.fetchOutput()
     myExpectedFile = os.path.join(shakemapZipDir(),
                                   myEventId + '.out.zip')
     myMessage = 'Expected path for downloaded shakemap OUT not received'
     self.assertEqual(myShakemapFile, myExpectedFile, myMessage)
Пример #7
0
 def testGetLatestShakeMap(self):
     """Check that we can retrieve the latest shake event"""
     # Simply dont set the event id in the ctor to get the latest
     myShakeData = ShakeData()
     myInpFile, myOutFile = myShakeData.fetchEvent()
     myEventId = myShakeData.eventId
     myExpectedInpFile = os.path.join(shakemapZipDir(),
                                      myEventId + '.inp.zip')
     myExpectedOutFile = os.path.join(shakemapZipDir(),
                                      myEventId + '.out.zip')
     myMessage = ('Expected path for downloaded shakemap INP not received'
          '\nExpected: %s\nGot: %s' %
          (myExpectedOutFile, myOutFile))
     self.assertEqual(myInpFile, myExpectedInpFile, myMessage)
     myMessage = ('Expected path for downloaded shakemap OUT not received'
          '\nExpected: %s\nGot: %s' %
          (myExpectedOutFile, myOutFile))
     self.assertEqual(myOutFile, myExpectedOutFile, myMessage)
Пример #8
0
 def testGetLatestShakeMap(self):
     """Check that we can retrieve the latest shake event"""
     # Simply dont set the event id in the ctor to get the latest
     myShakeData = ShakeData()
     myInpFile, myOutFile = myShakeData.fetchEvent()
     myEventId = myShakeData.eventId
     myExpectedInpFile = os.path.join(shakemapZipDir(),
                                      myEventId + '.inp.zip')
     myExpectedOutFile = os.path.join(shakemapZipDir(),
                                      myEventId + '.out.zip')
     myMessage = ('Expected path for downloaded shakemap INP not received'
                  '\nExpected: %s\nGot: %s' %
                  (myExpectedOutFile, myOutFile))
     self.assertEqual(myInpFile, myExpectedInpFile, myMessage)
     myMessage = ('Expected path for downloaded shakemap OUT not received'
                  '\nExpected: %s\nGot: %s' %
                  (myExpectedOutFile, myOutFile))
     self.assertEqual(myOutFile, myExpectedOutFile, myMessage)
Пример #9
0
 def test_shakemapZipDir(self):
     """Test we can get the shakemap zip dir"""
     myDir = shakemapZipDir()
     myExpectedDir = '/tmp/inasafe/realtime/shakemaps-zipped'
     assert os.path.exists(myExpectedDir)
     self.assertEqual(myDir, myExpectedDir)
Пример #10
0
 def test_shakemapZipDir(self):
     """Test we can get the shakemap zip dir"""
     myDir = shakemapZipDir()
     myExpectedDir = '/tmp/inasafe/realtime/shakemaps-zipped'
     assert os.path.exists(myExpectedDir)
     self.assertEqual(myDir, myExpectedDir)