Commit 4d5d24d1 authored by Thomas Vincent's avatar Thomas Vincent

Replace silx ExternalResources in place of XSocs one

parent f070707b
......@@ -42,7 +42,7 @@ import numpy as np
from silx.utils.testutils import ParametricTestCase
from xsocs import config
from xsocs.test.testfilesmanager import TestFilesManager
from xsocs.test.utils import test_resources
from xsocs.process.fit.peak_fit import PeakFitter
from xsocs.io.FitH5 import FitH5
......@@ -134,11 +134,9 @@ class TestPeakFitter(ParametricTestCase):
config.DEFAULT_PROCESS_NUMBER = 2 # Limit number of processes
cls._tmpdir = tempfile.mkdtemp()
manager = cls._manager = TestFilesManager('www.silx.org/pub/'
'xsocs/test_data/')
manager.checksum_lifetime = 0
manager.get_files('qspace')
manager.get_files('fit')
test_resources.getdir('qspace.zip')
test_resources.getdir('fit_2018_03.zip')
@classmethod
def tearDownClass(cls):
......@@ -155,8 +153,6 @@ class TestPeakFitter(ParametricTestCase):
self._tmpTestDir = None
def test_nominal(self):
manager = self._manager
keys = ['fit_f', 'qspace_f']
parameters = [
('gaussian_1.h5', 'qspace_1.h5'),
......@@ -170,8 +166,8 @@ class TestPeakFitter(ParametricTestCase):
with self.subTest(**params):
qspace_f = manager.get_file('qspace/{0}'
''.format(params['qspace_f']))
qspace_f = test_resources.getfile(
'qspace/{0}'.format(params['qspace_f']))
fit_out = os.path.join(self._tmpTestDir, params['fit_f'])
fitter = PeakFitter(qspace_f)
......@@ -186,8 +182,8 @@ class TestPeakFitter(ParametricTestCase):
results.to_fit_h5(fit_out)
fit_ref = manager.get_file('fit_2018_03/{0}'
''.format(params['fit_f']))
fit_ref = test_resources.getfile(
'fit_2018_03/{0}'.format(params['fit_f']))
fit_ref_h5 = FitH5(fit_ref)
fit_out_h5 = FitH5(fit_out)
......
......@@ -38,8 +38,7 @@ import unittest
from xsocs import config
from xsocs.test.testfilesmanager import TestFilesManager
from xsocs.test.utils import test_resources
from xsocs.process.merge.KmapMerger import KmapMerger
from xsocs.process.merge.KmapSpecParser import KmapSpecParser
......@@ -83,14 +82,10 @@ class TestMerger(unittest.TestCase):
cls._tmpdir = tempfile.mkdtemp()
cls._spec_h5 = os.path.join(cls._tmpdir, 'spec_h5.h5')
manager = cls._manager = TestFilesManager('www.silx.org/pub/'
'xsocs/test_data/spec')
manager.checksum_lifetime = 0
cls._manager.get_files('img')
cls._manager.get_files('spec')
spec_f = manager.get_file('spec/test.spec')
img_dir = manager.get_local_dir('img')
test_resources.getdir('spec.zip')
spec_f = test_resources.getfile('spec/spec/test.spec')
img_dir = os.path.dirname(
test_resources.getfile('spec/img/test_340800_0000.edf.gz'))
parser = cls._parser = KmapSpecParser(spec_f,
cls._spec_h5,
......
......@@ -36,7 +36,7 @@ import shutil
import tempfile
import unittest
from xsocs.test.testfilesmanager import TestFilesManager
from xsocs.test.utils import test_resources
from xsocs.process.merge.KmapSpecParser import KmapSpecParser
......@@ -64,13 +64,6 @@ class TestParser(unittest.TestCase):
'test_344000_0000.edf.gz',
'test_344200_0000.edf.gz'}
@classmethod
def setUpClass(cls):
cls._manager = TestFilesManager('www.silx.org/pub/'
'xsocs/test_data/spec/')
cls._manager.get_files('img')
cls._manager.get_files('spec')
def setUp(self):
self._tmpTestDir = tempfile.mkdtemp()
......@@ -81,9 +74,10 @@ class TestParser(unittest.TestCase):
def test_nominal(self):
"""
"""
manager = self._manager
spec_f = manager.get_file('spec/test.spec')
img_dir = manager.get_local_dir('img')
test_resources.getdir('spec.zip')
spec_f = test_resources.getfile('spec/spec/test.spec')
img_dir = os.path.dirname(
test_resources.getfile('spec/img/test_340800_0000.edf.gz'))
spec_h5 = os.path.join(self._tmpTestDir, 'spec.h5')
......
......@@ -39,7 +39,7 @@ import numpy as np
from silx.utils.testutils import ParametricTestCase
from xsocs import config
from xsocs.test.testfilesmanager import TestFilesManager
from xsocs.test.utils import test_resources
from xsocs.io.QSpaceH5 import QSpaceH5
from xsocs.io.XsocsH5 import XsocsH5
......@@ -54,11 +54,9 @@ class TestQSpace(ParametricTestCase):
config.DEFAULT_PROCESS_NUMBER = 2 # Limit number of processes
cls._tmpdir = tempfile.mkdtemp()
manager = cls._manager = TestFilesManager(
'www.silx.org/pub/xsocs/test_data/')
manager.checksum_lifetime = 0
manager.get_files('merged')
manager.get_files('qspace')
test_resources.getdir('merged.zip')
test_resources.getdir('qspace.zip')
@classmethod
def tearDownClass(cls):
......@@ -76,9 +74,7 @@ class TestQSpace(ParametricTestCase):
def test_nominal(self):
"""Test of QSpaceConverter"""
manager = self._manager
master_f = manager.get_file('merged/test.h5')
master_f = test_resources.getfile('merged/test.h5')
keys = ['output_f', 'medfilt_dims', 'mask']
parameters = [
......@@ -100,7 +96,7 @@ class TestQSpace(ParametricTestCase):
maskFilename = params['mask']
if maskFilename is not None: # Load mask
mask = np.load(manager.get_file('qspace/' + maskFilename))
mask = np.load(test_resources.getfile('qspace/' + maskFilename))
converter.mask = mask
converter.convert()
......@@ -109,8 +105,8 @@ class TestQSpace(ParametricTestCase):
converter.DONE,
msg=converter.status_msg)
q_ref = manager.get_file('qspace/{0}'
''.format(params['output_f']))
q_ref = test_resources.getfile(
'qspace/{0}'.format(params['output_f']))
q_out = converter.results
q_ref_h5 = QSpaceH5(q_ref)
......@@ -124,10 +120,8 @@ class TestQSpace(ParametricTestCase):
def test_normalization(self):
"""Test QSpaceConverter with normalization"""
manager = self._manager
output_f = os.path.join(self._tmpTestDir, 'qspace_normalization.h5')
master_f = manager.get_file('merged/test.h5')
master_f = test_resources.getfile('merged/test.h5')
normalizer = 'ccdint1'
master_h5 = XsocsH5(master_f)
......
This diff is collapsed.
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2018 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/
"""Shared test resource manager
"""
from silx.resources import ExternalResources
test_resources = ExternalResources(
project="xsocs",
url_base="http://www.silx.org/pub/xsocs/test_data",
env_key="XSOCS_DATA")
"""Shared test resources manager"""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment