def test_get_images_download_remote(self): localpath = self._make_paths(self.mangaredux, mode='local', inputs=[self.new_plateifu]) remotepath = self._make_paths(self.remoteredux, mode='remote', inputs=[self.new_plateifu]) self.assertFalse(os.path.isfile(localpath[0])) image = getImagesByList([self.new_plateifu], mode='remote', as_url=True, download=True) self.assertTrue(os.path.isfile(localpath[0])) self.assertIsNone(image)
def test_get_images_download_local_fail(self): localpath = self._make_paths(self.mangaredux, mode='local', inputs=[self.new_plateifu]) remotepath = self._make_paths(self.remoteredux, mode='remote', inputs=[self.new_plateifu]) self.assertFalse(os.path.isfile(localpath[0])) errmsg = 'Download not available when in local mode' with warnings.catch_warnings(record=True) as cm: warnings.simplefilter("always") image = getImagesByList([self.new_plateifu], mode='local', as_url=True, download=True) self.assertIs(cm[-1].category, MarvinUserWarning) self.assertIn(errmsg, str(cm[-1].message))
def test_get_imagelist(self, make_paths, mode, asurl, release): images = getImagesByList(imagelist, mode=mode, as_url=asurl, release=release) assert set(make_paths) == set(images)
def test_failures(self, imglist, mode, errmsg, release): with pytest.raises(AssertionError) as cm: image = getImagesByList(imglist, mode=mode, release=release) assert cm.type == AssertionError assert errmsg in str(cm.value)
def _get_imagelist(self, explist, inputlist=None, mode=None, as_url=None): images = getImagesByList(inputlist, mode=mode, as_url=as_url) self.assertListEqual(explist, images)
def test_notvalid_mode(self): errmsg = 'Mode must be either auto, local, or remote' with self.assertRaises(AssertionError) as cm: image = getImagesByList(self.imagelist, mode='notvalidmode') self.assertIn(errmsg, str(cm.exception))
def test_notvalid_objectid(self): errmsg = 'Input must be of type plate-ifu or mangaid' with self.assertRaises(AssertionError) as cm: image = getImagesByList(['nogoodid'], mode='local') self.assertIn(errmsg, str(cm.exception))
def test_notvalid_input(self): errmsg = 'Input must be of type list or Numpy array' with self.assertRaises(AssertionError) as cm: image = getImagesByList(self.new_plateifu, mode='local') self.assertIn(errmsg, str(cm.exception))