From e9d977d4e5851754dc06a173cf98519359399f69 Mon Sep 17 00:00:00 2001 From: naglepuff Date: Mon, 31 Oct 2022 14:20:26 -0400 Subject: [PATCH 1/7] Set up default config tests --- tests/data/default_schema_deidUpload.csv | 5 +++ tests/datastore.py | 16 ++++++++ tests/test_workflow.py | 31 +++++++++++++- tests/utilities.py | 51 +++++++++++++++++++++++- tox.ini | 1 + 5 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 tests/data/default_schema_deidUpload.csv diff --git a/tests/data/default_schema_deidUpload.csv b/tests/data/default_schema_deidUpload.csv new file mode 100644 index 00000000..b829cbe7 --- /dev/null +++ b/tests/data/default_schema_deidUpload.csv @@ -0,0 +1,5 @@ +TokenID,SurgPathNum,Registry,First_Name,Last_Name,Date_of_Birth_mmddyyyy,Tumor_Rec_Number,Histology_Code,Behavior_Code +0590XY112001,S16-1234,66,Natalina,Eltun,12012008,01,9440,3 +0590XY112002,C17-3456,66,Moria,Sterman,12012009,01,9440,3 +0590XY112003,C16-9876,66,Aila,Neles,11012009,01,9530,3 +0590XY112004,S17-3421,66,Shaylah,Hardacre,12012009,01,9440,3 diff --git a/tests/datastore.py b/tests/datastore.py index 7e6379d5..03eb479e 100644 --- a/tests/datastore.py +++ b/tests/datastore.py @@ -14,6 +14,14 @@ 'philips.ptif': 'sha512:ec0ec688537080e4ec2abb3978c14577df87250a2c0af42beaadc8f00f0baba210997d5d2fe7cfeeceb841885b6adad0c9f607e35eddcc479eb487bd3c1e28ac', # noqa } +default_registry = { + 'SEER_Mouse_1_17158539.svs': 'sha512:1ace33abb4bf96382c8823706c43deb1115b08d46bf96e2b03f425697a85e767631f0dc5568cce68c9110f1df66d264a97671fd488466f3cf59295513d6c7792', # noqa + 'SEER_Mouse_1_17158540.svs': 'sha512:74a0d97e9f8e3f42409c10be37eca9fb5d3be06f0a4f258d4b58efb5adc67f3f787a868bce6aa75649d25b221f4a0b32109bcc1ca1c696d4060981cb7d6b65f1', # noqa + 'SEER_Mouse_1_17158541.svs': 'sha512:f5fcbc5f31201ff7a28886d2b386a34fe9c0eb84cf9ce4e30601e6abe43c120ed242e23b1af555e69abab7823aef59a7220e6159b12f2cf565a2de69eb2cf1cb', # noqa + 'SEER_Mouse_1_17158542.svs': 'sha512:e763630a72b307932c64e442253fbf3c1877e7c9db77abb93864d37418fe7f94b9ace5286dff44ff0242ca1acfc58e3282b71959a864abdd925dc409452e40b7', # noqa + 'SEER_Mouse_1_17158543.svs': 'sha512:60ef06d11da310b713327adcab122e128a8a9506a68047dcff3ac5a327766e168f97ec032ba92b997b0d83e455864f8f61998c8c5f24767471b8b3c951838de1' # noqa +} + class DKCPooch(pooch.Pooch): def get_url(self, fname): @@ -29,3 +37,11 @@ def get_url(self, fname): base_url='https://data.kitware.com/api/v1/file/hashsum/{algo}/{hashvalue}/download', registry=registry, ) + +lowres_datastore = DKCPooch( + path=pooch.utils.cache_location( + os.path.join(os.environ.get('TOX_WORK_DIR', pooch.utils.os_cache('pooch')), 'dkc_datastore') + ), + base_url='https://data.kitware.com/api/v1/file/hashsum/{algo}/{hashvalue}/download', + registry=default_registry +) diff --git a/tests/test_workflow.py b/tests/test_workflow.py index 76bbf725..58293309 100644 --- a/tests/test_workflow.py +++ b/tests/test_workflow.py @@ -6,7 +6,7 @@ from girder.models.item import Item from girder.models.setting import Setting -from .utilities import provisionServer # noqa +from .utilities import provisionDefaultSchemaServer, provisionServer # noqa @pytest.mark.plugin('wsi_deid') @@ -72,3 +72,32 @@ def test_workflow_with_options(server, provisionServer, user): # noqa assert len(list(Folder().fileList(finishedFolder))) == 3 rest.exportData(user, False) assert len(os.listdir(exportPath)) == 3 + + +@pytest.mark.plugin('wsi_deid') +@pytest.mark.plugin('large_image') +def test_workflow_with_default_schema(server, provisionDefaultSchemaServer, user, mocker): # noqa + import wsi_deid.import_export + from wsi_deid import rest + from wsi_deid.constants import PluginSettings + + def mockStartOcrForUnfiled(*args): + return None + + mocker.patch('wsi_deid.import_export.startOcrJobForUnfiled', mockStartOcrForUnfiled) + + config = girder.utility.config.getConfig() + config[wsi_deid.config.CONFIG_SECTION] = { + 'import_text_association_columns': [ + 'SurgPathNum', + 'First_Name', + 'Last_Name', + 'Date_of_Birth_mmddyyyy' + ] + } + + unfiledFolderId = Setting().get(PluginSettings.WSI_DEID_UNFILED_FOLDER) + unfiledFolder = Folder().load(unfiledFolderId, force=True, exc=True) + assert len(list(Folder().fileList(unfiledFolder))) == 0 + rest.ingestData(user, False) + assert len(list(Folder().fileList(unfiledFolder, user, data=False))) == 5 diff --git a/tests/utilities.py b/tests/utilities.py index f48684e6..074aa574 100644 --- a/tests/utilities.py +++ b/tests/utilities.py @@ -7,7 +7,7 @@ from wsi_deid.constants import PluginSettings -from .datastore import datastore +from .datastore import datastore, lowres_datastore @pytest.fixture @@ -20,6 +20,11 @@ def provisionBoundServer(boundServer, admin, fsAssetstore, tmp_path): yield _provisionServer(tmp_path) +@pytest.fixture +def provisionDefaultSchemaServer(server, admin, fsAssetstore, tmp_path): + yield _provisionDefaultSchemaServer(tmp_path) + + def _provisionServer(tmp_path): sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'devops', 'wsi_deid')) import provision # noqa @@ -51,3 +56,47 @@ def resetConfig(): # Use default wsi_deid config for tests config = girder.utility.config.getConfig() config[wsi_deid.config.CONFIG_SECTION] = {} + + +@pytest.fixture +def _provisionDefaultSchemaServer(tmp_path): + import girder.utility.config # noqa + + import wsi_deid.config # noqa + sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'devops', 'wsi_deid')) + config = girder.utility.config.getConfig() + config[wsi_deid.config.CONFIG_SECTION] = { + 'import_text_association_columns': [ + 'SurgPathNum', + 'First_Name', + 'Last_Name', + 'Date_of_Birth_mmddyyyy' + ] + } + import provision # noqa + provision.provision() + del sys.path[-1] + + importPath = tmp_path / 'import' + os.makedirs(importPath, exist_ok=True) + exportPath = tmp_path / 'export' + os.makedirs(exportPath, exist_ok=True) + # unfiledPath = tmp_path / 'unfiled' + # os.makedirs(unfiledPath, exist_ok=True) + Setting().set(PluginSettings.WSI_DEID_IMPORT_PATH, str(importPath)) + Setting().set(PluginSettings.WSI_DEID_EXPORT_PATH, str(exportPath)) + # Setting().set(PluginSettings.WSI_DEID_UNFILED_FOLDER, str(unfiledPath)) + for filename in { + 'SEER_Mouse_1_17158539.svs', + 'SEER_Mouse_1_17158540.svs', + 'SEER_Mouse_1_17158541.svs', + 'SEER_Mouse_1_17158542.svs', + 'SEER_Mouse_1_17158543.svs' + }: + path = lowres_datastore.fetch(filename) + shutil.copy(path, str(importPath / filename)) + dataPath = os.path.join(os.path.dirname(__file__), 'data') + for filename in {'default_schema_deidUpload.csv'}: + path = os.path.join(dataPath, filename) + shutil.copy(path, importPath / filename) + return importPath, exportPath diff --git a/tox.ini b/tox.ini index 062d9b0f..50597fc5 100644 --- a/tox.ini +++ b/tox.ini @@ -10,6 +10,7 @@ deps = coverage pooch pytest + pytest-mock pytest-cov pytest-girder pytest-xdist From ec077a00c80703b95582dc5d28737be86ccd8c66 Mon Sep 17 00:00:00 2001 From: naglepuff Date: Wed, 9 Nov 2022 13:58:35 -0500 Subject: [PATCH 2/7] Add new client spec for default schema --- .../tests/wsi_deidDefaultSchemaSpec.js | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 wsi_deid/web_client/tests/wsi_deidDefaultSchemaSpec.js diff --git a/wsi_deid/web_client/tests/wsi_deidDefaultSchemaSpec.js b/wsi_deid/web_client/tests/wsi_deidDefaultSchemaSpec.js new file mode 100644 index 00000000..c859f4e4 --- /dev/null +++ b/wsi_deid/web_client/tests/wsi_deidDefaultSchemaSpec.js @@ -0,0 +1,105 @@ +/* globals girderTest, describe, it, expect, waitsFor, runs, $ */ + +girderTest.importPlugin('homepage', 'jobs', 'large_image', 'large_image_annotation', 'slicer_cli_web', 'histomicsui', 'wsi_deid') + +girderTest.startApp(); + +var tokenId = '0590XY112001'; + +describe('Mock WebGL', function () { + it('mock Webgl', function () { + var girder = window.girder; + var GeojsViewer = girder.plugins.large_image.views.imageViewerWidget.geojs; + girder.utilities.PluginUtils.wrap(GeojsViewer, 'initialize', function (initialize) { + this.once('g:beforeFirstRender', function () { + window.geo.util.restoreWebglRenderer(); + window.geo.util.mockWebglRenderer(); + }); + initialize.apply(this, arguments); + }); + }); +}); + +describe('Test WSI DeID plugin with default schema', function () { + describe('import', function () { + it('logs in as admin', function () { + girderTest.login('admin', 'Admin', 'Admin', 'password')(); + waitsFor(function() { + return $('a.g-nav-link[g-target="admin"]').length > 0; + }, 'admin console link to load'); + }); + it('goes to the WSI DeID collections page', function () { + runs(function () { + $('a.g-nav-link[g-target="collections"]').click(); + }); + girderTest.waitForLoad(); + waitsFor(function () { + return $('.g-collection-create-button:visible').length > 0; + }); + runs(function() { + $('.g-collection-list-entry .g-collection-link').click(); + }); + girderTest.waitForLoad(); + }); + it('goes to the unfiled folder', function () { + runs(function () { + expect($('.g-folder-list-link').eq(8).text()).toEqual('Unfiled'); + $('.g-folder-list-link').eq(8).click(); + }); + girderTest.waitForLoad(); + waitsFor(function () { + return $('.wsi_deid-import-button').length; + }, 'import button to appear'); + }); + it('clicks the import button', function () { + runs(function () { + $('.wsi_deid-import-button').click(); + }); + waitsFor(function () { + return $('.g-item-list-entry').length + }, 'imported images to load as items'); + girderTest.waitForLoad(); + }); + it('expects 1 to be 1', function () { + runs(function () { + expect(1).toBe(1); + }); + }); + }); + describe('refile one image', function () { + it('checks length of items', function () { + expect($('.g-item-list-entry').length).toEqual(5); + }); + it('opens the first item', function () { + runs(function () { + $('.g-item-list-link').eq(0).click(); + }); + girderTest.waitForLoad(); + waitsFor(function () { + return $('.g-refile-button').length + }, 'refile button to appear'); + }); + it('refiles the image', function () { + runs(function () { + var tokenInput = $('input.g-refile-tokenid').first(); + tokenInput.val(tokenId); + }); + runs(function () { + expect($('input.g-refile-tokenid').first().val()).toEqual(tokenId); + }); + runs(function () { + $('.g-refile-button').first().click(); + }); + girderTest.waitForLoad(); + waitsFor(function () { + return $('.g-hui-redact').length; + }); + waitsFor(function () { + return $('.g-workflow-button[action="process"]').length; + }, 'redaction controls to become available'); + runs(function () { + expect($('.g-workflow-button[action="process"]').length).toBe(1); + }); + }); + }); +}); From 0c5012b7a7aa591d756247ba377379914b773a7f Mon Sep 17 00:00:00 2001 From: naglepuff Date: Wed, 9 Nov 2022 13:59:01 -0500 Subject: [PATCH 3/7] Add fixtures and tests to run new client spec --- tests/test_web_client.py | 15 ++++++++++++++- tests/utilities.py | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/test_web_client.py b/tests/test_web_client.py index 1033557e..b5ab66a6 100644 --- a/tests/test_web_client.py +++ b/tests/test_web_client.py @@ -3,7 +3,7 @@ import pytest from pytest_girder.web_client import runWebClientTest -from .utilities import provisionBoundServer, resetConfig # noqa +from .utilities import provisionDefaultSchemaBoundServer, provisionBoundServer, resetConfig # noqa @pytest.mark.plugin('wsi_deid') @@ -17,3 +17,16 @@ def testWebClient(boundServer, db, spec, provisionBoundServer, resetConfig): # os.path.dirname(wsi_deid.import_export.SCHEMA_FILE_PATH), 'importManifestSchema.test.json') spec = os.path.join(os.path.dirname(__file__), '..', 'wsi_deid', 'web_client', 'tests', spec) runWebClientTest(boundServer, spec, 15000) + + +@pytest.mark.plugin('wsi_deid') +@pytest.mark.parametrize('spec', ( + 'wsi_deidDefaultSchemaSpec.js', +)) +def testDefaultSchemaWebClient(boundServer, db, spec, provisionDefaultSchemaBoundServer, mocker): # noqa + def mockStartOcrForUnfiled(*args): + return None + + mocker.patch('wsi_deid.import_export.startOcrJobForUnfiled', mockStartOcrForUnfiled) + specPath = os.path.join(os.path.dirname(__file__), '..', 'wsi_deid', 'web_client', 'tests', spec) + runWebClientTest(boundServer, specPath, 15000) diff --git a/tests/utilities.py b/tests/utilities.py index 074aa574..9ae10203 100644 --- a/tests/utilities.py +++ b/tests/utilities.py @@ -25,6 +25,11 @@ def provisionDefaultSchemaServer(server, admin, fsAssetstore, tmp_path): yield _provisionDefaultSchemaServer(tmp_path) +@pytest.fixture +def provisionDefaultSchemaBoundServer(boundServer, admin, fsAssetstore, tmp_path): + yield _provisionDefaultSchemaServer(tmp_path) + + def _provisionServer(tmp_path): sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'devops', 'wsi_deid')) import provision # noqa From c4580ed7c778f8465ec2ce461a76d2cf7b54c80c Mon Sep 17 00:00:00 2001 From: naglepuff Date: Wed, 9 Nov 2022 16:39:28 -0500 Subject: [PATCH 4/7] Add test for bulk refile together with new token --- .../tests/wsi_deidDefaultSchemaSpec.js | 89 +++++++++++++++++-- 1 file changed, 84 insertions(+), 5 deletions(-) diff --git a/wsi_deid/web_client/tests/wsi_deidDefaultSchemaSpec.js b/wsi_deid/web_client/tests/wsi_deidDefaultSchemaSpec.js index c859f4e4..b67644cb 100644 --- a/wsi_deid/web_client/tests/wsi_deidDefaultSchemaSpec.js +++ b/wsi_deid/web_client/tests/wsi_deidDefaultSchemaSpec.js @@ -5,6 +5,7 @@ girderTest.importPlugin('homepage', 'jobs', 'large_image', 'large_image_annotati girderTest.startApp(); var tokenId = '0590XY112001'; +var usedTokenIds = [tokenId]; describe('Mock WebGL', function () { it('mock Webgl', function () { @@ -60,11 +61,6 @@ describe('Test WSI DeID plugin with default schema', function () { }, 'imported images to load as items'); girderTest.waitForLoad(); }); - it('expects 1 to be 1', function () { - runs(function () { - expect(1).toBe(1); - }); - }); }); describe('refile one image', function () { it('checks length of items', function () { @@ -102,4 +98,87 @@ describe('Test WSI DeID plugin with default schema', function () { }); }); }); + describe('refile multiple images together under new TokenID', function () { + it('goes to the WSI DeID collections page', function () { + runs(function () { + $('a.g-nav-link[g-target="collections"]').click(); + }); + girderTest.waitForLoad(); + waitsFor(function () { + return $('.g-collection-create-button:visible').length > 0; + }); + runs(function() { + $('.g-collection-list-entry .g-collection-link').click(); + }); + girderTest.waitForLoad(); + }); + it('goes to the unfiled folder', function () { + runs(function () { + expect($('.g-folder-list-link').eq(8).text()).toEqual('Unfiled'); + $('.g-folder-list-link').eq(8).click(); + }); + girderTest.waitForLoad(); + waitsFor(function () { + return $('.wsi_deid-import-button').length; + }, 'import button to appear'); + }); + it('selects multiple images for refile', function () { + runs(function () { + var checkboxes = $('input.g-list-checkbox'); + checkboxes.eq(0).click(); + checkboxes.eq(1).click(); + waitsFor(function () { + return $('.g-refile-button').length; + }, 'refile button to appear'); + }); + }); + it('refiles the images', function () { + runs(function () { + $('.g-refile-button').first().click(); + }); + girderTest.waitForLoad(); + runs(function () { + expect($('.g-item-list-entry').length).toEqual(2); + }); + }); + it('goes to the WSI DeID collections page', function () { + runs(function () { + $('a.g-nav-link[g-target="collections"]').click(); + }); + girderTest.waitForLoad(); + waitsFor(function () { + return $('.g-collection-create-button:visible').length > 0; + }); + runs(function() { + $('.g-collection-list-entry .g-collection-link').click(); + }); + girderTest.waitForLoad(); + }); + it('verifies a new folder in AvailableToProcess', function () { + runs(function () { + expect($('.g-folder-list-link').eq(1).text()).toEqual('AvailableToProcess'); + $('.g-folder-list-link').eq(1).click(); + }); + girderTest.waitForLoad(); + waitsFor(function () { + return $('.wsi_deid-import-button').length; + }, 'import button to appear'); + runs(function () { + expect($('.g-folder-list-link').length).toEqual(2); + }); + }); + it('verifies 2 images in new folder', function () { + runs(function () { + var newFolder = $('.g-folder-list-link').filter(function () { + return $(this).text() !== tokenId; + }).first(); + usedTokenIds.push(newFolder.text()); + newFolder.click(); + }); + girderTest.waitForLoad(); + runs(function () { + expect($('.g-item-list-entry').length).toEqual(2); + }); + }); + }); }); From 0c9b51e95302ef24cfceaa0127310c10512529a3 Mon Sep 17 00:00:00 2001 From: naglepuff Date: Fri, 11 Nov 2022 14:08:39 -0500 Subject: [PATCH 5/7] Add test for refiling checked items separately --- tests/test_web_client.py | 8 +- .../tests/wsi_deidDefaultSchemaSpec.js | 111 ++++++++++++++++-- 2 files changed, 110 insertions(+), 9 deletions(-) diff --git a/tests/test_web_client.py b/tests/test_web_client.py index b5ab66a6..01dd0f5d 100644 --- a/tests/test_web_client.py +++ b/tests/test_web_client.py @@ -28,5 +28,11 @@ def mockStartOcrForUnfiled(*args): return None mocker.patch('wsi_deid.import_export.startOcrJobForUnfiled', mockStartOcrForUnfiled) - specPath = os.path.join(os.path.dirname(__file__), '..', 'wsi_deid', 'web_client', 'tests', spec) + specPath = os.path.join( + os.path.dirname(__file__), + '..', 'wsi_deid', + 'web_client', + 'tests', + spec + ) runWebClientTest(boundServer, specPath, 15000) diff --git a/wsi_deid/web_client/tests/wsi_deidDefaultSchemaSpec.js b/wsi_deid/web_client/tests/wsi_deidDefaultSchemaSpec.js index b67644cb..c6842c1e 100644 --- a/wsi_deid/web_client/tests/wsi_deidDefaultSchemaSpec.js +++ b/wsi_deid/web_client/tests/wsi_deidDefaultSchemaSpec.js @@ -1,6 +1,6 @@ -/* globals girderTest, describe, it, expect, waitsFor, runs, $ */ +/* globals girder, girderTest, describe, it, expect, waitsFor, runs, $ */ -girderTest.importPlugin('homepage', 'jobs', 'large_image', 'large_image_annotation', 'slicer_cli_web', 'histomicsui', 'wsi_deid') +girderTest.importPlugin('homepage', 'jobs', 'large_image', 'large_image_annotation', 'slicer_cli_web', 'histomicsui', 'wsi_deid'); girderTest.startApp(); @@ -25,7 +25,7 @@ describe('Test WSI DeID plugin with default schema', function () { describe('import', function () { it('logs in as admin', function () { girderTest.login('admin', 'Admin', 'Admin', 'password')(); - waitsFor(function() { + waitsFor(function () { return $('a.g-nav-link[g-target="admin"]').length > 0; }, 'admin console link to load'); }); @@ -37,7 +37,7 @@ describe('Test WSI DeID plugin with default schema', function () { waitsFor(function () { return $('.g-collection-create-button:visible').length > 0; }); - runs(function() { + runs(function () { $('.g-collection-list-entry .g-collection-link').click(); }); girderTest.waitForLoad(); @@ -57,7 +57,7 @@ describe('Test WSI DeID plugin with default schema', function () { $('.wsi_deid-import-button').click(); }); waitsFor(function () { - return $('.g-item-list-entry').length + return $('.g-item-list-entry').length; }, 'imported images to load as items'); girderTest.waitForLoad(); }); @@ -72,7 +72,7 @@ describe('Test WSI DeID plugin with default schema', function () { }); girderTest.waitForLoad(); waitsFor(function () { - return $('.g-refile-button').length + return $('.g-refile-button').length; }, 'refile button to appear'); }); it('refiles the image', function () { @@ -107,7 +107,7 @@ describe('Test WSI DeID plugin with default schema', function () { waitsFor(function () { return $('.g-collection-create-button:visible').length > 0; }); - runs(function() { + runs(function () { $('.g-collection-list-entry .g-collection-link').click(); }); girderTest.waitForLoad(); @@ -149,7 +149,7 @@ describe('Test WSI DeID plugin with default schema', function () { waitsFor(function () { return $('.g-collection-create-button:visible').length > 0; }); - runs(function() { + runs(function () { $('.g-collection-list-entry .g-collection-link').click(); }); girderTest.waitForLoad(); @@ -181,4 +181,99 @@ describe('Test WSI DeID plugin with default schema', function () { }); }); }); + describe('refile multiple images separately under new TokenIDs', function () { + it('goes to the WSI DeID collections page', function () { + runs(function () { + $('a.g-nav-link[g-target="collections"]').click(); + }); + girderTest.waitForLoad(); + waitsFor(function () { + return $('.g-collection-create-button:visible').length > 0; + }); + runs(function () { + $('.g-collection-list-entry .g-collection-link').click(); + }); + girderTest.waitForLoad(); + }); + it('goes to the unfiled folder', function () { + runs(function () { + expect($('.g-folder-list-link').eq(8).text()).toEqual('Unfiled'); + $('.g-folder-list-link').eq(8).click(); + }); + girderTest.waitForLoad(); + waitsFor(function () { + return $('.wsi_deid-import-button').length; + }, 'import button to appear'); + }); + it('selects multiple images for refile', function () { + runs(function () { + var checkboxes = $('input.g-list-checkbox'); + checkboxes.eq(0).click(); + checkboxes.eq(1).click(); + waitsFor(function () { + return $('.g-refile-button').length; + }, 'refile button to appear'); + }); + }); + it('refiles the images separately', function () { + runs(function () { + var togetherSelect = $('.g-refile-select-togetherness').first(); + togetherSelect.val('separately'); + $('.g-refile-button').first().click(); + }); + girderTest.waitForLoad(); + runs(function () { + expect($('.g-item-list-entry').length).toEqual(0); + }); + }); + it('goes to the WSI DeID collections page', function () { + runs(function () { + $('a.g-nav-link[g-target="collections"]').click(); + }); + girderTest.waitForLoad(); + waitsFor(function () { + return $('.g-collection-create-button:visible').length > 0; + }); + runs(function () { + $('.g-collection-list-entry .g-collection-link').click(); + }); + girderTest.waitForLoad(); + }); + it('verifies two new folders in AvailableToProcess', function () { + runs(function () { + expect($('.g-folder-list-link').eq(1).text()).toEqual('AvailableToProcess'); + $('.g-folder-list-link').eq(1).click(); + }); + girderTest.waitForLoad(); + waitsFor(function () { + return $('.wsi_deid-import-button').length; + }, 'import button to appear'); + runs(function () { + expect($('.g-folder-list-link').length).toEqual(4); + }); + }); + it('verifies one image in each of the new folders', function () { + var newFolders; + runs(function () { + newFolders = $('.g-folder-list-link').filter(function () { + return !usedTokenIds.includes($(this).text()); + }); + expect(newFolders.length).toEqual(2); + var imageCount = new Array(newFolders.length).fill(0); + newFolders.each(function (index, folder) { + var folderId = $(folder).attr('href').split('/')[1]; + girder.rest.restRequest({ + url: 'item?folderId=' + folderId + }).done(function (response) { + imageCount[index] = response.length; + }); + waitsFor(function () { + return imageCount.length === imageCount.filter(function (val) { + return val === 1; + }).length; + }); + }); + }); + }); + }); }); From 3e11a11b2a24081801e9d6c2587402f3796829c2 Mon Sep 17 00:00:00 2001 From: naglepuff Date: Tue, 15 Nov 2022 14:25:52 -0500 Subject: [PATCH 6/7] Consolidate data stores Each utility function for provisioning web servers enumerates the files to use. Therefore they can share the data stores without necessarily sharing the files. --- tests/datastore.py | 12 +----------- tests/utilities.py | 5 ++--- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/tests/datastore.py b/tests/datastore.py index 03eb479e..cdef1d6f 100644 --- a/tests/datastore.py +++ b/tests/datastore.py @@ -12,9 +12,7 @@ # Philips file # Source: sample_image.ptif 'philips.ptif': 'sha512:ec0ec688537080e4ec2abb3978c14577df87250a2c0af42beaadc8f00f0baba210997d5d2fe7cfeeceb841885b6adad0c9f607e35eddcc479eb487bd3c1e28ac', # noqa -} - -default_registry = { + # Sample mouse tissue files to use with default schema tests 'SEER_Mouse_1_17158539.svs': 'sha512:1ace33abb4bf96382c8823706c43deb1115b08d46bf96e2b03f425697a85e767631f0dc5568cce68c9110f1df66d264a97671fd488466f3cf59295513d6c7792', # noqa 'SEER_Mouse_1_17158540.svs': 'sha512:74a0d97e9f8e3f42409c10be37eca9fb5d3be06f0a4f258d4b58efb5adc67f3f787a868bce6aa75649d25b221f4a0b32109bcc1ca1c696d4060981cb7d6b65f1', # noqa 'SEER_Mouse_1_17158541.svs': 'sha512:f5fcbc5f31201ff7a28886d2b386a34fe9c0eb84cf9ce4e30601e6abe43c120ed242e23b1af555e69abab7823aef59a7220e6159b12f2cf565a2de69eb2cf1cb', # noqa @@ -37,11 +35,3 @@ def get_url(self, fname): base_url='https://data.kitware.com/api/v1/file/hashsum/{algo}/{hashvalue}/download', registry=registry, ) - -lowres_datastore = DKCPooch( - path=pooch.utils.cache_location( - os.path.join(os.environ.get('TOX_WORK_DIR', pooch.utils.os_cache('pooch')), 'dkc_datastore') - ), - base_url='https://data.kitware.com/api/v1/file/hashsum/{algo}/{hashvalue}/download', - registry=default_registry -) diff --git a/tests/utilities.py b/tests/utilities.py index 9ae10203..8c9aeece 100644 --- a/tests/utilities.py +++ b/tests/utilities.py @@ -7,7 +7,7 @@ from wsi_deid.constants import PluginSettings -from .datastore import datastore, lowres_datastore +from .datastore import datastore @pytest.fixture @@ -63,7 +63,6 @@ def resetConfig(): config[wsi_deid.config.CONFIG_SECTION] = {} -@pytest.fixture def _provisionDefaultSchemaServer(tmp_path): import girder.utility.config # noqa @@ -98,7 +97,7 @@ def _provisionDefaultSchemaServer(tmp_path): 'SEER_Mouse_1_17158542.svs', 'SEER_Mouse_1_17158543.svs' }: - path = lowres_datastore.fetch(filename) + path = datastore.fetch(filename) shutil.copy(path, str(importPath / filename)) dataPath = os.path.join(os.path.dirname(__file__), 'data') for filename in {'default_schema_deidUpload.csv'}: From 078b82096fdef1337a4866d913319697c28c31f8 Mon Sep 17 00:00:00 2001 From: naglepuff Date: Tue, 15 Nov 2022 15:20:37 -0500 Subject: [PATCH 7/7] Fix import order for isort --- tests/test_web_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_web_client.py b/tests/test_web_client.py index 01dd0f5d..121fe1ef 100644 --- a/tests/test_web_client.py +++ b/tests/test_web_client.py @@ -3,7 +3,7 @@ import pytest from pytest_girder.web_client import runWebClientTest -from .utilities import provisionDefaultSchemaBoundServer, provisionBoundServer, resetConfig # noqa +from .utilities import provisionBoundServer, provisionDefaultSchemaBoundServer, resetConfig # noqa @pytest.mark.plugin('wsi_deid')