def test_failures(self, galaxy, plateid, mode, errmsg): plateid = plateid if plateid else galaxy.plate with pytest.raises(AssertionError) as cm: image = getImagesByPlate(plateid, mode=mode, release=galaxy.release) assert cm.type == AssertionError assert errmsg in str(cm.value)
def test_realimages(self, release): imfiles = getImagesByPlate(plateid='8485', as_url=True, mode='local', release=release) images = buildImageDict(imfiles) names = [im['name'] for im in images] assert images assert '8485-1901' in names assert 'https://data.sdss.org/sas/mangawork/manga/spectro/redux/' in images[ 0]['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 = getImagesByPlate(self.new_plate, mode='local', as_url=True, download=True) self.assertIs(cm[-1].category, MarvinUserWarning) self.assertIn(errmsg, str(cm[-1].message))
def test_get_images_download_remote(self): self._update_release('MPL-4') config.forceDbOff() self._get_cube() 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 = getImagesByPlate(self.new_plate, mode='remote', as_url=True, download=True) self.assertTrue(os.path.isfile(localpath[0])) self.assertIsNone(image)
def test_get_imageplate(self, make_paths, plate, mode, asurl, release): images = getImagesByPlate(plate, mode=mode, as_url=asurl, release=release) assert make_paths[0] in images
def _get_imageplate(self, explist, plate=None, mode=None, as_url=None): images = getImagesByPlate(plate, mode=mode, as_url=as_url) self.assertIn(explist[0], images)
def test_notvalid_mode(self): errmsg = 'Mode must be either auto, local, or remote' with self.assertRaises(AssertionError) as cm: image = getImagesByPlate(self.plate, mode='notvalidmode') self.assertIn(errmsg, str(cm.exception))
def test_notvalid_plate(self): errmsg = 'Plateid must be a numeric integer value' with self.assertRaises(AssertionError) as cm: image = getImagesByPlate('8485abc', mode='local') self.assertIn(errmsg, str(cm.exception))