Beispiel #1
0
class SpieTest(TestCase):
    """
    Tests the dataqs.spie module.  Since each processor is highly
    dependent on a running GeoNode instance for most functions, only
    independent functions are tested here.
    """
    def setUp(self):
        self.processor = SPEIProcessor()
        httpretty.enable()

    def tearDown(self):
        httpretty.disable()
        self.processor.cleanup()

    def test_download(self):
        """
        Verify that files are downloaded.
        """
        imgurl = "{}spei03.nc".format(self.processor.base_url)
        httpretty.register_uri(httpretty.GET, imgurl, body=get_mock_image())
        imgfile = self.processor.download(imgurl, 'spei03.tif')
        self.assertTrue(
            os.path.exists(os.path.join(self.processor.tmp_dir, imgfile)))

    def test_cleanup(self):
        """
        Temporary files should be gone after cleanup
        :return:
        """
        imgurl = "{}spei03.nc".format(self.processor.base_url)
        httpretty.register_uri(httpretty.GET, imgurl, body=get_mock_image())
        self.processor.download(imgurl, 'spei03.tif')
        self.assertNotEqual([],
                            glob.glob(
                                os.path.join(self.processor.tmp_dir,
                                             self.processor.prefix + '*')))
        self.processor.cleanup()
        self.assertEquals([],
                          glob.glob(
                              os.path.join(self.processor.tmp_dir,
                                           self.processor.prefix + '*')))
Beispiel #2
0
class SpieTest(TestCase):
    """
    Tests the dataqs.spie module.  Since each processor is highly
    dependent on a running GeoNode instance for most functions, only
    independent functions are tested here.
    """

    def setUp(self):
        self.processor = SPEIProcessor()
        httpretty.enable()

    def tearDown(self):
        httpretty.disable()
        self.processor.cleanup()

    def test_download(self):
        """
        Verify that files are downloaded.
        """
        imgurl = "{}spei03.nc".format(self.processor.base_url)
        httpretty.register_uri(httpretty.GET, imgurl,
                               body=get_mock_image())
        imgfile = self.processor.download(imgurl, 'spei03.tif')
        self.assertTrue(os.path.exists(os.path.join(
            self.processor.tmp_dir, imgfile)))

    def test_cleanup(self):
        """
        Temporary files should be gone after cleanup
        :return:
        """
        imgurl = "{}spei03.nc".format(self.processor.base_url)
        httpretty.register_uri(httpretty.GET, imgurl,
                               body=get_mock_image())
        self.processor.download(imgurl, 'spei03.tif')
        self.assertNotEqual([], glob.glob(os.path.join(
            self.processor.tmp_dir, self.processor.prefix + '*')))
        self.processor.cleanup()
        self.assertEquals([], glob.glob(os.path.join(
            self.processor.tmp_dir, self.processor.prefix + '*')))
Beispiel #3
0
 def setUp(self):
     self.processor = SPEIProcessor()
     httpretty.enable()
Beispiel #4
0
 def setUp(self):
     self.processor = SPEIProcessor()
     httpretty.enable()
Beispiel #5
0
def spei_task():
    processor = SPEIProcessor()
    processor.run()