Ejemplo n.º 1
0
    def test_pickling_file_custom_path(self):

        modelcube = ModelCube(filename=self.filename)

        test_path = '~/test.mpf'
        path = modelcube.save(path=test_path)
        self._files_created.append(path)

        self.assertTrue(os.path.exists(path))
        self.assertEqual(path, os.path.realpath(os.path.expanduser(test_path)))

        modelcube_restored = ModelCube.restore(path, delete=True)
        self.assertEqual(modelcube_restored.data_origin, 'file')
        self.assertIsInstance(modelcube_restored, ModelCube)
        self.assertIsNotNone(modelcube_restored.data)

        self.assertFalse(os.path.exists(path))
Ejemplo n.º 2
0
    def test_pickling_api(self, temp_scratch, galaxy):
        modelcube = ModelCube(plateifu=galaxy.plateifu,
                              bintype=galaxy.bintype,
                              mode='remote')
        assert modelcube.data_origin == 'api'
        assert isinstance(modelcube, ModelCube)
        assert modelcube.data is None

        file = temp_scratch.join('test_modelcube_api.mpf')
        modelcube.save(str(file))

        assert file.check() is True

        modelcube = None
        assert modelcube is None

        modelcube_restored = ModelCube.restore(str(file))
        assert modelcube_restored.data_origin == 'api'
        assert isinstance(modelcube_restored, ModelCube)
        assert modelcube_restored.data is None
Ejemplo n.º 3
0
    def test_pickling_file_custom_path(self, temp_scratch, galaxy):
        modelcube = ModelCube(filename=galaxy.modelpath,
                              bintype=galaxy.bintype)
        assert modelcube.data_origin == 'file'
        assert isinstance(modelcube, ModelCube)
        assert modelcube.data is not None

        file = temp_scratch.join('mcpickle').join('test_modelcube.mpf')
        assert file.check(file=1) is False

        path = modelcube.save(path=str(file))
        assert file.check() is True
        assert os.path.exists(path)

        modelcube_restored = ModelCube.restore(str(file), delete=True)
        assert modelcube_restored.data_origin == 'file'
        assert isinstance(modelcube_restored, ModelCube)
        assert modelcube_restored.data is not None

        assert not os.path.exists(path)
Ejemplo n.º 4
0
    def test_pickling_file(self, temp_scratch, galaxy):
        modelcube = ModelCube(filename=galaxy.modelpath,
                              bintype=galaxy.bintype)
        assert modelcube.data_origin == 'file'
        assert isinstance(modelcube, ModelCube)
        assert modelcube.data is not None

        file = temp_scratch.join('test_modelcube.mpf')
        modelcube.save(str(file))

        assert file.check() is True
        assert modelcube.data is not None

        modelcube = None
        assert modelcube is None

        modelcube_restored = ModelCube.restore(str(file))
        assert modelcube_restored.data_origin == 'file'
        assert isinstance(modelcube_restored, ModelCube)
        assert modelcube_restored.data is not None
Ejemplo n.º 5
0
    def test_pickling_api(self):

        modelcube = ModelCube(plateifu=self.plateifu, mode='remote')
        self.assertEqual(modelcube.data_origin, 'api')
        self.assertIsInstance(modelcube, ModelCube)
        self.assertIsNone(modelcube.data)

        path = modelcube.save()
        self._files_created.append(path)

        self.assertTrue(os.path.exists(path))
        self.assertEqual(os.path.realpath(path),
                         os.path.realpath(self.filename[0:-7] + 'mpf'))

        modelcube = None
        self.assertIsNone(modelcube)

        modelcube_restored = ModelCube.restore(path)
        self.assertEqual(modelcube_restored.data_origin, 'api')
        self.assertIsInstance(modelcube_restored, ModelCube)
        self.assertIsNone(modelcube_restored.data)
        self.assertEqual(modelcube_restored.header['VERSDRP3'], 'v2_0_1')
Ejemplo n.º 6
0
    def test_pickling_file(self):

        modelcube = ModelCube(filename=self.filename)
        self.assertEqual(modelcube.data_origin, 'file')
        self.assertIsInstance(modelcube, ModelCube)
        self.assertIsNotNone(modelcube.data)

        path = modelcube.save()
        self._files_created.append(path)

        self.assertTrue(os.path.exists(path))
        self.assertEqual(os.path.realpath(path),
                         os.path.realpath(self.filename[0:-7] + 'mpf'))
        self.assertIsNotNone(modelcube.data)

        modelcube = None
        self.assertIsNone(modelcube)

        modelcube_restored = ModelCube.restore(path)
        self.assertEqual(modelcube_restored.data_origin, 'file')
        self.assertIsInstance(modelcube_restored, ModelCube)
        self.assertIsNotNone(modelcube_restored.data)