Esempio n. 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)
Esempio n. 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)
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
0
 def testFileNames(self):
     """Check we compute file names properly."""
     myShakeEvent = '20120726022003'
     myShakeData = ShakeData(myShakeEvent)
     myExpectedInpFileName = '20120726022003.inp.zip'
     myExpectedOutFileName = '20120726022003.out.zip'
     myInpFileName, myOutFileName = myShakeData.fileNames()
     myMessage = 'Expected: %s\nGot: %s' % (
         myExpectedInpFileName, myInpFileName)
     assert myInpFileName == myExpectedInpFileName, myMessage
     myMessage = 'Expected: %s\nGot: %s' % (
         myExpectedOutFileName, myOutFileName)
     assert myOutFileName == myExpectedOutFileName, myMessage
Esempio n. 6
0
 def testCachePaths(self):
     """Check we compute local cache paths properly."""
     myShakeEvent = '20120726022003'
     myShakeData = ShakeData(myShakeEvent)
     myExpectedInpPath = ('/tmp/inasafe/realtime/shakemaps-zipped/'
                          '20120726022003.inp.zip')
     myExpectedOutPath = ('/tmp/inasafe/realtime/shakemaps-zipped/'
                          '20120726022003.out.zip')
     myInpPath, myOutPath = myShakeData.cachePaths()
     myMessage = 'Expected: %s\nGot: %s' % (myExpectedInpPath, myInpPath)
     assert myInpPath == myExpectedInpPath, myMessage
     myMessage = 'Expected: %s\nGot: %s' % (myExpectedOutPath, myOutPath)
     assert myOutPath == myExpectedOutPath, myMessage
Esempio n. 7
0
    def testExtractShakeMap(self):
        """Test that we can extract the shakemap inp and out files"""
        myShakeEvent = '20120726022003'
        myShakeData = ShakeData(myShakeEvent)
        myGridXml = myShakeData.extract(theForceFlag=True)

        myExtractDir = shakemapExtractDir()

        myExpectedGridXml = (os.path.join(myExtractDir,
                           '20120726022003/grid.xml'))
        myMessage = 'Expected: %s\nGot: %s\n' % (myExpectedGridXml, myGridXml)
        assert myExpectedGridXml in myExpectedGridXml, myMessage
        assert os.path.exists(myGridXml)
Esempio n. 8
0
 def testFileNames(self):
     """Check we compute file names properly."""
     myShakeEvent = '20120726022003'
     myShakeData = ShakeData(myShakeEvent)
     myExpectedInpFileName = '20120726022003.inp.zip'
     myExpectedOutFileName = '20120726022003.out.zip'
     myInpFileName, myOutFileName = myShakeData.fileNames()
     myMessage = 'Expected: %s\nGot: %s' % (myExpectedInpFileName,
                                            myInpFileName)
     assert myInpFileName == myExpectedInpFileName, myMessage
     myMessage = 'Expected: %s\nGot: %s' % (myExpectedOutFileName,
                                            myOutFileName)
     assert myOutFileName == myExpectedOutFileName, myMessage
Esempio n. 9
0
 def testCachePaths(self):
     """Check we compute local cache paths properly."""
     myShakeEvent = '20120726022003'
     myShakeData = ShakeData(myShakeEvent)
     myExpectedInpPath = ('/tmp/inasafe/realtime/shakemaps-zipped/'
                          '20120726022003.inp.zip')
     myExpectedOutPath = ('/tmp/inasafe/realtime/shakemaps-zipped/'
                          '20120726022003.out.zip')
     myInpPath, myOutPath = myShakeData.cachePaths()
     myMessage = 'Expected: %s\nGot: %s' % (myExpectedInpPath, myInpPath)
     assert myInpPath == myExpectedInpPath, myMessage
     myMessage = 'Expected: %s\nGot: %s' % (myExpectedOutPath, myOutPath)
     assert myOutPath == myExpectedOutPath, myMessage
Esempio n. 10
0
    def testExtractShakeMap(self):
        """Test that we can extract the shakemap inp and out files"""
        myShakeEvent = '20120726022003'
        myShakeData = ShakeData(myShakeEvent)
        myGridXml = myShakeData.extract(theForceFlag=True)

        myExtractDir = shakemapExtractDir()

        myExpectedGridXml = (os.path.join(myExtractDir,
                                          '20120726022003/grid.xml'))
        myMessage = 'Expected: %s\nGot: %s\n' % (myExpectedGridXml, myGridXml)
        assert myExpectedGridXml in myExpectedGridXml, myMessage
        assert os.path.exists(myGridXml)
Esempio n. 11
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)
Esempio n. 12
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)
Esempio n. 13
0
 def testCheckEventIsOnServer(self):
     """Test that we can check if an event is on the server."""
     myShakeEvent = '20120726022003'
     myShakeData = ShakeData(myShakeEvent)
     self.assertTrue(myShakeData.isOnServer(),
                     ('Data for %s is on server' % myShakeEvent))
Esempio n. 14
0
 def testCheckEventIsOnServer(self):
     """Test that we can check if an event is on the server."""
     myShakeEvent = '20120726022003'
     myShakeData = ShakeData(myShakeEvent)
     self.assertTrue(myShakeData.isOnServer(),
                     ('Data for %s is on server' % myShakeEvent))