r = requests.get(DATA_KITWARE_URL) _ = r.content except requests.ConnectionError: internet_available = False def gen_response(content, status_code=200): resp = requests.Response() resp._content = content resp.status_code = status_code resp.headers['content-length'] = len(content) return resp # Only perform these tests if the implementation is usable. @pytest.mark.skipif(not GirderDataElement.is_usable(), reason="GirderDataElement reports as not usable.") class TestGirderDataElement(unittest.TestCase): """ Tests for the GirderDataElement plugin implementation """ LOCAL_APIROOT = "http://localhost:8080/api/v1" EXAMPLE_ITEM_ID = '5820bbeb8d777f10f26efc2f' EXAMPLE_GIRDER_API_ROOT = "%s/api/v1" % DATA_KITWARE_URL EXAMPLE_GIRDER_FULL_URI = ( EXAMPLE_GIRDER_API_ROOT.replace('https', 'girder') + '/file/%s' % EXAMPLE_ITEM_ID) EXAMPLE_PTH = os.path.join(TEST_DATA_DIR, 'Lenna.png') EXAMPLE_SHA512 = 'ca2be093f4f25d2168a0afebe013237efce02197bcd8a87f41f' \
r = requests.get(DATA_KITWARE_URL) _ = r.content except requests.ConnectionError: internet_available = False def gen_response(content, status_code=200): resp = requests.Response() resp._content = content resp.status_code = status_code resp.headers['content-length'] = len(content) return resp # Only perform these tests if the implementation is usable. if GirderDataElement.is_usable(): class TestGirderDataElement (unittest.TestCase): """ Tests for the GirderDataElement plugin implementation """ LOCAL_APIROOT = "http://localhost:8080/api/v1" EXAMPLE_ITEM_ID = '5820bbeb8d777f10f26efc2f' EXAMPLE_GIRDER_API_ROOT = "%s/api/v1" % DATA_KITWARE_URL EXAMPLE_GIRDER_FULL_URI = ( EXAMPLE_GIRDER_API_ROOT.replace('https', 'girder') + '/file/%s' % EXAMPLE_ITEM_ID ) EXAMPLE_PTH = os.path.join(TEST_DATA_DIR, 'Lenna.png')