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)
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))
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))
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)
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)
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)