From 004d6bd9a7a401f4e5fafff2f24dd2c9dbdd6150 Mon Sep 17 00:00:00 2001 From: k1o0 Date: Mon, 15 Jul 2019 22:40:42 +0300 Subject: [PATCH 1/9] Fixes for test conflicts --- +eui/AlyxPanel.m | 2 +- alyx-matlab | 2 +- tests/AlyxPanel_test.m | 62 ++++++++++++++++++-------------------- tests/sinusoidLayer_test.m | 49 ------------------------------ 4 files changed, 32 insertions(+), 83 deletions(-) delete mode 100644 tests/sinusoidLayer_test.m diff --git a/+eui/AlyxPanel.m b/+eui/AlyxPanel.m index 41241600..2bfb34a2 100644 --- a/+eui/AlyxPanel.m +++ b/+eui/AlyxPanel.m @@ -478,7 +478,7 @@ function recordWeight(obj, weight, subject) % See also LAUNCHSESSIONURL ai = obj.AlyxInstance; s = ai.getData(ai.makeEndpoint(['subjects/' obj.Subject])); - url = fullfile(ai.BaseURL, 'admin', 'subjects', 'subject', s.id, 'change'); % this is wrong - need uuid + url = sprintf('%s/admin/subjects/subject/%s/change', ai.BaseURL, s.id); stat = web(url, '-browser'); end diff --git a/alyx-matlab b/alyx-matlab index 85b5915a..b5694156 160000 --- a/alyx-matlab +++ b/alyx-matlab @@ -1 +1 @@ -Subproject commit 85b5915a15eb833fff9b304bf068a0766a1fe8b9 +Subproject commit b569415668e1396eec568ef87653953c27b7f1a6 diff --git a/tests/AlyxPanel_test.m b/tests/AlyxPanel_test.m index 5a4dbb6b..d3e5228c 100644 --- a/tests/AlyxPanel_test.m +++ b/tests/AlyxPanel_test.m @@ -29,6 +29,12 @@ GraphData end + properties (ClassSetupParameter) + % Alyx base URL. test is for the main branch, testDev is for the dev + % code + BaseURL = cellsprintf('https://%s.alyx.internationalbrainlab.org', {'test', 'testDev'}); + end + methods (TestClassSetup) function killFigures(testCase) testCase.FigureVisibleDefault = get(0,'DefaultFigureVisible'); @@ -46,7 +52,7 @@ function loadData(testCase) testCase.GraphData = graphData; end - function setupPanel(testCase) + function setupPanel(testCase, BaseURL) % Check paths file assert(endsWith(which('dat.paths'), fullfile('fixtures','+dat','paths.m'))); % Check temp mainRepo folder is empty. An extra safe measure as we @@ -59,6 +65,16 @@ function setupPanel(testCase) localRepo = dat.reposPath('main','local'); if exist(localRepo, 'dir') == 0; mkdir(localRepo); end + % Create config directory + assert(mkdir(getOr(dat.paths,'rigConfig')), 'Failed to create config directory') + % Add teardown to remove folders + rmFcn = @(repo)assert(rmdir(repo, 's'), 'Failed to remove test repo %s', repo); + addTeardown(testCase, rmFcn, getOr(dat.paths, 'globalConfig')) + + % Set the database url + paths.databaseURL = BaseURL; + save(fullfile(getOr(dat.paths,'rigConfig'), 'paths'), 'paths') + % Create figure for panel testCase.hPanel = figure('Name', 'alyx GUI',... 'MenuBar', 'none',... @@ -87,11 +103,13 @@ function setupPanel(testCase) % MControl using this as a panel. testCase.SubjectUI.addlistener('SelectionChanged', ... @(src, evt)testCase.Panel.dispWaterReq(src, evt)); - + % Set Alyx Instance and log in testCase.Panel.login('test_user', 'TapetesBloc18'); testCase.fatalAssertTrue(testCase.Panel.AlyxInstance.IsLoggedIn,... 'Failed to log into Alyx'); + testCase.fatalAssertEqual(testCase.Panel.AlyxInstance.BaseURL, BaseURL,... + 'Failed to correctly set database url'); % Verify subject folders created present = ismember([{'default'}; testCase.Subjects(1:end-1)], dat.listSubjects); @@ -214,7 +232,7 @@ function test_dispWaterReq(testCase) testCase.verifyTrue(~strcmp(prev, new), 'Failed to retrieve new data') end - function test_launchSessionURL(testCase) + function test_launchSessionURL(testCase, BaseURL) % Test the launch of the session page in the admin Web interface p = testCase.Panel; testCase.Mock.InTest = true; @@ -234,8 +252,7 @@ function test_launchSessionURL(testCase) expected = url; else uuid = todaySession.url(find(todaySession.url=='/', 1, 'last')+1:end); - expected = ['https://test.alyx.internationalbrainlab.org/admin/', ... - 'actions/session/', uuid, '/change']; + expected = [BaseURL '/admin/actions/session/', uuid, '/change']; end testCase.verifyEqual(url, expected, 'Unexpected url') @@ -243,15 +260,15 @@ function test_launchSessionURL(testCase) % todo: close tab after opening? (for `test_launchSubjectURL` as well) end - function test_launchSubjectURL(testCase) + function test_launchSubjectURL(testCase, BaseURL) % Test the launch of the subject page in the admin Web interface p = testCase.Panel; % Set new subject testCase.SubjectUI.Selected = testCase.SubjectUI.Option{2}; [failed, url] = p.launchSubjectURL; testCase.verifyTrue(~failed, 'Failed to launch subject page in browser') - expected = ['https:\\test.alyx.internationalbrainlab.org\admin\'... - 'subjects\subject\bcefd268-68c2-4ea8-9b60-588ee4e99ebb\change']; + expected = [BaseURL '/admin/subjects/subject/'... + 'bcefd268-68c2-4ea8-9b60-588ee4e99ebb/change']; testCase.verifyEqual(url, expected, 'unexpected subject page url') end @@ -481,16 +498,11 @@ function test_activeFlag(testCase) button = findobj(testCase.Parent, 'String', str); testCase.assertEqual(button.Enable, 'on', 'AlyxPanel not enabled') - % Comment out the databaseURL field in the paths file - fid = fopen(which('dat.paths')); - data = cellflat(textscan(fid, '%s', 'Delimiter', '\n', 'CollectOutput', true)); - fclose(fid); - - data{startsWith(data,'p.databaseURL')} = ['%' data{startsWith(data,'p.databaseURL')}]; - - fid = fopen(which('dat.paths'), 'w'); - cellfun(@(ln)fprintf(fid, '%s\n', ln), data); - fclose(fid); + % Set invalid database URL + paths.databaseURL = ''; + save(fullfile(getOr(dat.paths,'rigConfig'), 'paths'), 'paths') + testCase.assertEqual(paths.databaseURL, getOr(dat.paths,'databaseURL'),... + 'Failed to create custom paths file') testCase.Figure = figure('Name', testCase.Subjects{end}); eui.AlyxPanel(testCase.Figure); @@ -502,20 +514,6 @@ function test_activeFlag(testCase) 'AlyxPanel enabled while databaseURL undefined') close(testCase.Figure) - % Restore paths - fid = fopen(which('dat.paths')); - data = cellflat(textscan(fid, '%s', 'Delimiter', '\n', 'CollectOutput', true)); - fclose(fid); - - idx = startsWith(data,'%p.databaseURL'); - if any(idx) - data{idx}(1) = []; - fid = fopen(which('dat.paths'), 'w'); - cellfun(@(ln)fprintf(fid, '%s\n', ln), data); - fclose(fid); - testCase.fatalAssertTrue(~isempty(getOr(dat.paths, 'databaseURL')), ... - 'Failed to restore databaseURL field in paths') - end end function test_round(testCase) diff --git a/tests/sinusoidLayer_test.m b/tests/sinusoidLayer_test.m deleted file mode 100644 index 41fe9001..00000000 --- a/tests/sinusoidLayer_test.m +++ /dev/null @@ -1,49 +0,0 @@ -%% Test 1: vis.grating default values -azimuth = 0; spatialFreq = 1/15; phase = 0; orientation = 0; -[layer, image] = vis.sinusoidLayer(azimuth, spatialFreq, phase, orientation); -TestAns = [layer.texOffset(1), layer.texAngle, layer.size(1)]; -ExpectedAns = [0 0 15]; -assert(isequal(TestAns,ExpectedAns), 'Test 1 failed.'); - -%% Test 2: Negative Azimuth -azimuth = -90; spatialFreq = 1/15; phase = 0; orientation = 0; -[layer, image] = vis.sinusoidLayer(azimuth, spatialFreq, phase, orientation); -TestAns = [layer.texOffset(1), layer.texAngle, layer.size(1)]; -ExpectedAns = [-90 0 15]; -assert(isequal(TestAns,ExpectedAns), 'Test 2 failed.'); - -%% Test 3: High Spatial Frequency -azimuth = 0; spatialFreq = 2; phase = 0; orientation = 0; -[layer, image] = vis.sinusoidLayer(azimuth, spatialFreq, phase, orientation); -TestAns = round([layer.texOffset(1), layer.texAngle, layer.size(1)],4); -ExpectedAns = [0 0 0.5000]; -assert(isequal(TestAns,ExpectedAns), 'Test 3 failed.'); - - -%% Test 4: Negative Phase -azimuth = 0; spatialFreq = 1/15; phase = -90; orientation = 0; -[layer, image] = vis.sinusoidLayer(azimuth, spatialFreq, phase, orientation); -TestAns = round([layer.texOffset(1), layer.texAngle, layer.size(1)],4); -ExpectedAns = [10.1408 0 15.0000]; -assert(isequal(TestAns,ExpectedAns), 'Test 4 failed.'); - -%% Test 5: Negative Orientation -azimuth = 0; spatialFreq = 1/15; phase = 0; orientation = -90; -[layer, image] = vis.sinusoidLayer(azimuth, spatialFreq, phase, orientation); -TestAns = [layer.texOffset(1), layer.texAngle, layer.size(1)]; -ExpectedAns = [0 -90 15]; -assert(isequal(TestAns,ExpectedAns), 'Test 5 failed.'); - -%% Test 6: Non-zero values for all input args -azimuth = 45; spatialFreq = 7/15; phase = 30; orientation = 60; -[layer, image] = vis.sinusoidLayer(azimuth, spatialFreq, phase, orientation); -TestAns = round([layer.texOffset(1), layer.texAngle, layer.size(1)],4); -ExpectedAns = [24.1600 60.0000 2.1429]; -assert(isequal(TestAns,ExpectedAns), 'Test 6 failed.'); - -%% Test 7: Impossible Spatial Frequency -azimuth = 45; spatialFreq = -1/15; phase = 30; orientation = 60; -[layer, image] = vis.sinusoidLayer(azimuth, spatialFreq, phase, orientation); -TestAns = round([layer.texOffset(1), layer.texAngle, layer.size(1)],4); -ExpectedAns = [10.8803 60.0000 -15.0000]; -assert(isequal(TestAns,ExpectedAns), 'Test 7 failed.'); \ No newline at end of file From 20cb546ef1fe56cf1e1eee2ca50a1fa6ba4154ea Mon Sep 17 00:00:00 2001 From: k1o0 Date: Tue, 16 Jul 2019 08:11:00 +0100 Subject: [PATCH 2/9] Ensure path is reset --- tests/AlyxPanel_test.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/AlyxPanel_test.m b/tests/AlyxPanel_test.m index d3e5228c..2992f968 100644 --- a/tests/AlyxPanel_test.m +++ b/tests/AlyxPanel_test.m @@ -487,7 +487,7 @@ function test_giveFutureWater(testCase) 'Failed to add training dates to saved params') end - function test_activeFlag(testCase) + function test_activeFlag(testCase, BaseURL) % Ensure that the panel is active when the DatabaseURL is added and % not empty @@ -507,7 +507,10 @@ function test_activeFlag(testCase) testCase.Figure = figure('Name', testCase.Subjects{end}); eui.AlyxPanel(testCase.Figure); - testCase.assertEmpty(getOr(dat.paths, 'databaseURL'), ... + % Reset URL + paths.databaseURL = BaseURL; + save(fullfile(getOr(dat.paths,'rigConfig'), 'paths'), 'paths') + testCase.fatalAssertEqual(getOr(dat.paths, 'databaseURL'), BaseURL, ... 'Failed to remove databaseURL field in paths') button = findobj(testCase.Figure, 'String', 'Login'); testCase.verifyEqual(button.Enable, 'off', ... From 629ec27439574f001deaf14477cb15c7c553fe01 Mon Sep 17 00:00:00 2001 From: k1o0 Date: Tue, 16 Jul 2019 08:58:20 +0100 Subject: [PATCH 3/9] Issue #180 --- tests/AlyxPanel_test.m | 1 + tests/dat_test.m | 2 ++ 2 files changed, 3 insertions(+) diff --git a/tests/AlyxPanel_test.m b/tests/AlyxPanel_test.m index 2992f968..29bebc15 100644 --- a/tests/AlyxPanel_test.m +++ b/tests/AlyxPanel_test.m @@ -510,6 +510,7 @@ function test_activeFlag(testCase, BaseURL) % Reset URL paths.databaseURL = BaseURL; save(fullfile(getOr(dat.paths,'rigConfig'), 'paths'), 'paths') + clearCBToolsCache % Ensure paths are reloaded testCase.fatalAssertEqual(getOr(dat.paths, 'databaseURL'), BaseURL, ... 'Failed to remove databaseURL field in paths') button = findobj(testCase.Figure, 'String', 'Login'); diff --git a/tests/dat_test.m b/tests/dat_test.m index 796788a0..f3050093 100644 --- a/tests/dat_test.m +++ b/tests/dat_test.m @@ -112,6 +112,7 @@ function test_paths(testCase) paths.main2Repository = [p.mainRepository '2']; paths.altRepository = [p.mainRepository '3']; save(fullfile(p.rigConfig, 'paths'), 'paths') + clearCBToolsCache p = dat.paths('testRig'); testCase.verifyTrue(ismember('novelRepo', fieldnames(p)), ... @@ -312,6 +313,7 @@ function altMain2Paths(testCase) 'Secondary main repo already in path, expected otherwise') paths.main2Repository = [dat.reposPath('main','m') '2']; save(fullfile(getOr(dat.paths,'rigConfig'), 'paths'), 'paths') + clearCBToolsCache % Ensure paths are reloaded testCase.assertEqual(paths.main2Repository, getOr(dat.paths,'main2Repository'),... 'Failed to create custom paths file') end From 539e77cfe695c97fa52b9a8c30ed85be16a9a835 Mon Sep 17 00:00:00 2001 From: HForrest Date: Wed, 17 Jul 2019 12:57:18 +0100 Subject: [PATCH 4/9] a fix to AlyxPanel_test/setupPanel, but still failing --- +eui/AlyxPanel.m | 2 +- cortexlab/+git/changes.m | 6 ------ tests/AlyxPanel_test.m | 17 +++++++++++++---- tests/runall.m | 1 - 4 files changed, 14 insertions(+), 12 deletions(-) delete mode 100644 cortexlab/+git/changes.m diff --git a/+eui/AlyxPanel.m b/+eui/AlyxPanel.m index 2bfb34a2..8c4dec4b 100644 --- a/+eui/AlyxPanel.m +++ b/+eui/AlyxPanel.m @@ -202,7 +202,7 @@ parent.Sizes = [50 150 150]; else % Use parent's logging display - obj.LoggingDisplay = findobj('Tag', 'Logging Display'); + obj.LoggingDisplay = findobj(parent, 'Tag', 'Logging Display'); end end diff --git a/cortexlab/+git/changes.m b/cortexlab/+git/changes.m deleted file mode 100644 index d9e9f013..00000000 --- a/cortexlab/+git/changes.m +++ /dev/null @@ -1,6 +0,0 @@ -disp('Updating queued Alyx posts...') -posts = dirPlus(getOr(dat.paths, 'localAlyxQueue', 'C:/localAlyxQueue')); -posts = posts(endsWith(posts, 'put')); -newPosts = cellfun(@(str)[str(1:end-3) 'patch'], posts, 'uni', 0); -status = cellfun(@movefile, posts, newPosts); -assert(all(status), 'Unable to rename queued Alyx files, please do this manually') \ No newline at end of file diff --git a/tests/AlyxPanel_test.m b/tests/AlyxPanel_test.m index 29bebc15..39a7f5c9 100644 --- a/tests/AlyxPanel_test.m +++ b/tests/AlyxPanel_test.m @@ -30,11 +30,18 @@ end properties (ClassSetupParameter) + % Alyx base URL. test is for the main branch, testDev is for the dev + % code + BaseURLTestSetup = cellsprintf('https://%s.alyx.internationalbrainlab.org', {'test', 'testDev'}); + end + + properties (TestParameter) % Alyx base URL. test is for the main branch, testDev is for the dev % code BaseURL = cellsprintf('https://%s.alyx.internationalbrainlab.org', {'test', 'testDev'}); end + %% methods (TestClassSetup) methods (TestClassSetup) function killFigures(testCase) testCase.FigureVisibleDefault = get(0,'DefaultFigureVisible'); @@ -52,7 +59,7 @@ function loadData(testCase) testCase.GraphData = graphData; end - function setupPanel(testCase, BaseURL) + function setupPanel(testCase, BaseURLTestSetup) % Check paths file assert(endsWith(which('dat.paths'), fullfile('fixtures','+dat','paths.m'))); % Check temp mainRepo folder is empty. An extra safe measure as we @@ -72,7 +79,7 @@ function setupPanel(testCase, BaseURL) addTeardown(testCase, rmFcn, getOr(dat.paths, 'globalConfig')) % Set the database url - paths.databaseURL = BaseURL; + paths.databaseURL = BaseURLTestSetup; save(fullfile(getOr(dat.paths,'rigConfig'), 'paths'), 'paths') % Create figure for panel @@ -108,7 +115,7 @@ function setupPanel(testCase, BaseURL) testCase.Panel.login('test_user', 'TapetesBloc18'); testCase.fatalAssertTrue(testCase.Panel.AlyxInstance.IsLoggedIn,... 'Failed to log into Alyx'); - testCase.fatalAssertEqual(testCase.Panel.AlyxInstance.BaseURL, BaseURL,... + testCase.fatalAssertEqual(testCase.Panel.AlyxInstance.BaseURL, BaseURLTestSetup,... 'Failed to correctly set database url'); % Verify subject folders created @@ -124,6 +131,7 @@ function setupPanel(testCase, BaseURL) end end + %% methods (TestClassTeardown) methods (TestClassTeardown) function restoreFigures(testCase) set(0,'DefaultFigureVisible',testCase.FigureVisibleDefault); @@ -165,7 +173,8 @@ function methodTaredown(testCase) testCase.Mock.reset; end end - + + %% methods (Test) methods (Test) function test_viewSubjectHistory(testCase) % Post some weights for plotting diff --git a/tests/runall.m b/tests/runall.m index d95cc4d3..a0fad759 100644 --- a/tests/runall.m +++ b/tests/runall.m @@ -3,7 +3,6 @@ % TODO May become a function % TODO May add flags for levels of testing % TODO Method setup in dat_test may become global fixture -% TODO Delete sinusoidLayer_test from this folder % TODO Deal with directory changes main_tests = testsuite; From d6b7deff06c363213bcbb299e681a48b7e2d97e3 Mon Sep 17 00:00:00 2001 From: k1o0 Date: Wed, 17 Jul 2019 19:07:57 +0300 Subject: [PATCH 5/9] Reverted some changes and added fix for activeFlag test --- +eui/AlyxPanel.m | 2 +- tests/AlyxPanel_test.m | 26 +++++++++----------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/+eui/AlyxPanel.m b/+eui/AlyxPanel.m index 8c4dec4b..2bfb34a2 100644 --- a/+eui/AlyxPanel.m +++ b/+eui/AlyxPanel.m @@ -202,7 +202,7 @@ parent.Sizes = [50 150 150]; else % Use parent's logging display - obj.LoggingDisplay = findobj(parent, 'Tag', 'Logging Display'); + obj.LoggingDisplay = findobj('Tag', 'Logging Display'); end end diff --git a/tests/AlyxPanel_test.m b/tests/AlyxPanel_test.m index 39a7f5c9..8c76e356 100644 --- a/tests/AlyxPanel_test.m +++ b/tests/AlyxPanel_test.m @@ -30,18 +30,11 @@ end properties (ClassSetupParameter) - % Alyx base URL. test is for the main branch, testDev is for the dev - % code - BaseURLTestSetup = cellsprintf('https://%s.alyx.internationalbrainlab.org', {'test', 'testDev'}); - end - - properties (TestParameter) % Alyx base URL. test is for the main branch, testDev is for the dev % code BaseURL = cellsprintf('https://%s.alyx.internationalbrainlab.org', {'test', 'testDev'}); end - %% methods (TestClassSetup) methods (TestClassSetup) function killFigures(testCase) testCase.FigureVisibleDefault = get(0,'DefaultFigureVisible'); @@ -59,7 +52,7 @@ function loadData(testCase) testCase.GraphData = graphData; end - function setupPanel(testCase, BaseURLTestSetup) + function setupPanel(testCase, BaseURL) % Check paths file assert(endsWith(which('dat.paths'), fullfile('fixtures','+dat','paths.m'))); % Check temp mainRepo folder is empty. An extra safe measure as we @@ -79,7 +72,7 @@ function setupPanel(testCase, BaseURLTestSetup) addTeardown(testCase, rmFcn, getOr(dat.paths, 'globalConfig')) % Set the database url - paths.databaseURL = BaseURLTestSetup; + paths.databaseURL = BaseURL; save(fullfile(getOr(dat.paths,'rigConfig'), 'paths'), 'paths') % Create figure for panel @@ -115,7 +108,7 @@ function setupPanel(testCase, BaseURLTestSetup) testCase.Panel.login('test_user', 'TapetesBloc18'); testCase.fatalAssertTrue(testCase.Panel.AlyxInstance.IsLoggedIn,... 'Failed to log into Alyx'); - testCase.fatalAssertEqual(testCase.Panel.AlyxInstance.BaseURL, BaseURLTestSetup,... + testCase.fatalAssertEqual(testCase.Panel.AlyxInstance.BaseURL, BaseURL,... 'Failed to correctly set database url'); % Verify subject folders created @@ -131,7 +124,6 @@ function setupPanel(testCase, BaseURLTestSetup) end end - %% methods (TestClassTeardown) methods (TestClassTeardown) function restoreFigures(testCase) set(0,'DefaultFigureVisible',testCase.FigureVisibleDefault); @@ -173,8 +165,7 @@ function methodTaredown(testCase) testCase.Mock.reset; end end - - %% methods (Test) + methods (Test) function test_viewSubjectHistory(testCase) % Post some weights for plotting @@ -496,7 +487,7 @@ function test_giveFutureWater(testCase) 'Failed to add training dates to saved params') end - function test_activeFlag(testCase, BaseURL) + function test_activeFlag(testCase) % Ensure that the panel is active when the DatabaseURL is added and % not empty @@ -508,19 +499,20 @@ function test_activeFlag(testCase, BaseURL) testCase.assertEqual(button.Enable, 'on', 'AlyxPanel not enabled') % Set invalid database URL + baseURL = testCase.Panel.AlyxInstance.BaseURL; paths.databaseURL = ''; save(fullfile(getOr(dat.paths,'rigConfig'), 'paths'), 'paths') - testCase.assertEqual(paths.databaseURL, getOr(dat.paths,'databaseURL'),... + testCase.assertEmpty(getOr(dat.paths,'databaseURL'),... 'Failed to create custom paths file') testCase.Figure = figure('Name', testCase.Subjects{end}); eui.AlyxPanel(testCase.Figure); % Reset URL - paths.databaseURL = BaseURL; + paths.databaseURL = baseURL; save(fullfile(getOr(dat.paths,'rigConfig'), 'paths'), 'paths') clearCBToolsCache % Ensure paths are reloaded - testCase.fatalAssertEqual(getOr(dat.paths, 'databaseURL'), BaseURL, ... + testCase.fatalAssertEqual(getOr(dat.paths, 'databaseURL'), baseURL, ... 'Failed to remove databaseURL field in paths') button = findobj(testCase.Figure, 'String', 'Login'); testCase.verifyEqual(button.Enable, 'off', ... From 829cac533509a9b13bffcb327ee92420a166b93b Mon Sep 17 00:00:00 2001 From: k1o0 Date: Thu, 18 Jul 2019 19:22:21 +0100 Subject: [PATCH 6/9] Bug fixes and updates for update to test db --- +eui/AlyxPanel.m | 4 ++-- tests/AlyxPanel_test.m | 23 +++++++++++------------ tests/fixtures/data/viewSubjectData.mat | Bin 8485 -> 8483 bytes 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/+eui/AlyxPanel.m b/+eui/AlyxPanel.m index 2bfb34a2..5c5c8242 100644 --- a/+eui/AlyxPanel.m +++ b/+eui/AlyxPanel.m @@ -411,12 +411,12 @@ function recordWeight(obj, weight, subject) ai = obj.AlyxInstance; % determine whether there is a session for this subj and date thisDate = ai.datestr(now); - sessions = ai.getData(['sessions?type=Base&subject=' obj.Subject]); + sessions = ai.getSessions('subject', obj.Subject, 'date', now); stat = -1; url = []; % If the date of this latest base session is not the same date % as today, then create a new one for today - if isempty(sessions) || ~strcmp(sessions(end).start_time(1:10), thisDate(1:10)) + if isempty(sessions) % Ask user whether he/she wants to create new session % Construct a questdlg with three options choice = questdlg('Would you like to create a new base session?', ... diff --git a/tests/AlyxPanel_test.m b/tests/AlyxPanel_test.m index 8c76e356..91c20df6 100644 --- a/tests/AlyxPanel_test.m +++ b/tests/AlyxPanel_test.m @@ -67,14 +67,11 @@ function setupPanel(testCase, BaseURL) % Create config directory assert(mkdir(getOr(dat.paths,'rigConfig')), 'Failed to create config directory') - % Add teardown to remove folders - rmFcn = @(repo)assert(rmdir(repo, 's'), 'Failed to remove test repo %s', repo); - addTeardown(testCase, rmFcn, getOr(dat.paths, 'globalConfig')) % Set the database url paths.databaseURL = BaseURL; save(fullfile(getOr(dat.paths,'rigConfig'), 'paths'), 'paths') - + clearCBToolsCache % Create figure for panel testCase.hPanel = figure('Name', 'alyx GUI',... 'MenuBar', 'none',... @@ -135,12 +132,11 @@ function restoreFigures(testCase) idx = cellfun(@(n)any(strcmp(n, testCase.Subjects)),{figHandles.Name}); close(figHandles(idx)) end - % Remove subject directories + % Remove directories + repos = [{getOr(dat.paths,'localAlyxQueue', ['fixtures' filesep 'alyxQ'])};... + dat.reposPath('main'); {getOr(dat.paths, 'globalConfig')}]; rm = @(repo)assert(rmdir(repo, 's'), 'Failed to remove test repo %s', repo); - cellfun(@(repo)iff(exist(repo,'dir') == 7, @()rm(repo), @()nop), dat.reposPath('main')); - % Remove Alyx queue - alyxQ = getOr(dat.paths,'localAlyxQueue', ['fixtures' filesep 'alyxQ']); - assert(rmdir(alyxQ, 's'), 'Failed to remove test Alyx queue') + cellfun(@(repo)iff(exist(repo,'dir') == 7, @()rm(repo), @()nop), repos); end end @@ -234,6 +230,8 @@ function test_dispWaterReq(testCase) function test_launchSessionURL(testCase, BaseURL) % Test the launch of the session page in the admin Web interface + % TODO Use DELETE to test both creating new session and viewing + % existing p = testCase.Panel; testCase.Mock.InTest = true; testCase.Mock.UseDefaults = false; @@ -244,10 +242,11 @@ function test_launchSessionURL(testCase, BaseURL) % Add mock user response key = 'Would you like to create a new base session?'; - testCase.Mock.Dialogs(key) = iff(isempty(todaySession), 'Yes', 'No'); + noSub = isempty(todaySession)||~isempty(todaySession.number); + testCase.Mock.Dialogs(key) = iff(noSub, 'Yes', 'No'); - [failed, url] = testCase.assertWarningFree(@()p.launchSessionURL); - testCase.verifyTrue(~failed, 'Failed to launch subject page in browser') + [status, url] = testCase.assertWarningFree(@()p.launchSessionURL); + testCase.verifyTrue(status > -1, 'Failed to launch subject page in browser') if isempty(todaySession) expected = url; else diff --git a/tests/fixtures/data/viewSubjectData.mat b/tests/fixtures/data/viewSubjectData.mat index bf68d0d2f1b8e52ab0cef40cce5f842b8185e9f2..0f356031fe4af775e47089cdb9bb797470b10963 100644 GIT binary patch delta 1228 zcmV;-1T*`kLZd>EgtPGxG!F$20001Ev4xWZf4vRDFc5_)fhq+xOE5svQL_X?&@%)K zL7gGU5P=d2fj|fe3Y6HFNGGhbV>l(D&PK+<&#& z<~+Y#{Qlwjk+^Gq?fPr;_(S>EZhvhrKFL4Md3}|J35{LHXUE(7e&f4;!sJKpe@*wN z9hdww^KSg>`~K~F{cv3B4_)_H{`}wWGmm^V+0FBVwm<%S{lUS(!NI}7!NI}7!NJ4u zbhwvrGke1%G!`jbR+X@mshdBixW=Z^_KaxJ5)L zdsb#y*(;RHWJHuv_9%N38Ihe;s+*CFN{SL0*}38H~gBrLRxsN>V!fq-)xFdb=iyUG{Ok%*bkwy&8T{%TheQUTR01 zT7TKat_o8;JAdJU(EZ&l_eI&J2>sD5PZ#rZe{X&rt3nN&4aM`L{S@tIM~QR(s9%1g zSehqT?0;%b*Fdj!YYK>S+S_~I^iL4K*DE^GMn6RCXDjHMSOsK#PRAIPk)Qjo-v1(63;PcvLwc7#NT^fzuS{6?5w-LOBLpk z>-BLP8WAsayWq<41MHK9o_D6P?vyz3cj6J07P?SJ-2c0C4o)-co9-o^zk0$VLw#ql zmoin2%w;WhZQa1u%Cvvy{!3lzQkS~ar7m@;Oa1@sz7<3E1Rsc#{+CK!>i<#Cr+5jm18ZR& ztcMNY2mY`THo<1t0$X7lY=<4N6MuHWZrB5RVIS;=05|{#ArKD1VK@RuAqbAaaR`PJ za1u_zX*dIC;T(j(dAI-<;SyYiPzZx75DpO#2`Y$!t8fjj!wrarn-BxH;5OWWyATU; z5D)ht0q#R0B*6oC2+5EFk02Eu!xKn@r|=A(!wX1*vtfE=_SC**?MpbdE-FXV&#paTV06%3&o7(sQY0X3l()P_1>40WL%)Q1LO0u7-NG=?Ui1XD1BrqB$` zp*gew3upMl zoG*v(Vfzr|+frANt8u+5brwCPNu`T`(Uwb{-p^qjY@Z`PfWv%V>89nBy)HiNALcMO zjW0I0%`fCt&hFOszUpVnVLj|WjP2@I3$IVv+kU<+cin%~`K0nM-yfus57W=}e<-`B zW`EQ?_W7XVcdei6fBA7e-@fm+@3{YJb( znB)3N^-~x_$7ja7`+noPfBfW!?tg9frx~aG)AKO?#lC-IukVjj{ULOJ#m|53{wNls z&9vAl`~BC~pE+~p%$YN1&O9`4{$9(RIdkU!!?W@7Fw2gj5cz(h{&z@H%qe^3%$e)? z3$uX~cm;oXP>f+5!11kEk|S)c03sGay0y zUeD-AYyGogKW(Vj(0pIk=d_PeRr7cK_50u^S7lg-h&|Clp(9TbyU)(Z;Oh}tpEJ&& z`?`NQ4&pfmO}%3rM*Y3#^}9W(wT*@4yEI`QdC`8eheyN<-6phB{2<#Dq34-ZN6+Q1 z_&ae6Nx!sMSKR-*a}G^!*8hd4c)sr>4Qa}w)TRD^_JnD&VfOK{(*IJaOZ`9UdDVZfgNgn?VG+2) zV(x4hXB|B8(|Y{hApraw!wDT0Xu(T z7wm>T5D0r=AMA%92!;c25Dvj%2!SJT6hh$`9ETHd5>CNsI0I+l9E8DnxBwU75`@EL zxB?Ln2`Y$!t8fjj!wrarn-BxBa0_n39f*Uw5D)ht0q#R0B*6nnh7?GJhmZ!3;4!4b z6L<>G;5od2m+%T+!y9-D@8CUTfXsj7D-F;DEyxDhK@K?}Cul=1(1F~L2l7Hb(1rX^ z01AQv^q>$Fh9XcDih({92LmVpC7~3QhB8nV%0YQBgbGj*DnVta0!C03szG(A0me`h zYC&zN19hPu)Q1Mp5E?;aXaY?^2`11CnnMdPg_h6?T0x0fxgfW`ojPi2)1AcgJ3WWfuS%A>|r>JfRQi?M#C5w z3*%rsOn`~t0Fz)cOaVu5f~lWTdwPiKNvd< Ww7W*>QF@f79}NI$qUlVrfH)5k0#zUY From 3725fe90d493e890bf608dd79389213d90f82a42 Mon Sep 17 00:00:00 2001 From: k1o0 Date: Thu, 18 Jul 2019 21:05:28 +0100 Subject: [PATCH 7/9] Changes to alyx-matlab --- alyx-matlab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alyx-matlab b/alyx-matlab index b5694156..407b7ff6 160000 --- a/alyx-matlab +++ b/alyx-matlab @@ -1 +1 @@ -Subproject commit b569415668e1396eec568ef87653953c27b7f1a6 +Subproject commit 407b7ff63beba94840354fe16154ee21a6079b61 From 7b9aa728b190ba46d2cc4a6761df67156dd3a7d4 Mon Sep 17 00:00:00 2001 From: k1o0 Date: Thu, 18 Jul 2019 21:22:37 +0100 Subject: [PATCH 8/9] Fix to recordWeight test --- tests/AlyxPanel_test.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/AlyxPanel_test.m b/tests/AlyxPanel_test.m index 91c20df6..416465be 100644 --- a/tests/AlyxPanel_test.m +++ b/tests/AlyxPanel_test.m @@ -290,7 +290,7 @@ function test_recordWeight(testCase) 'Failed to update weight label color') % Post weight < 80 - weight = 28 + rand; + weight = 16 + rand; testCase.Panel.recordWeight(weight) expected = sprintf('Weight today: %.2f (< 80%%)', weight); testCase.verifyTrue(startsWith(strip(weight_text.String(2,:)), expected),... From f0a19d5f34a2160982f032fa5525d6e3425d94ef Mon Sep 17 00:00:00 2001 From: k1o0 Date: Thu, 18 Jul 2019 21:38:38 +0100 Subject: [PATCH 9/9] Fix for db bug cause submodule test fail --- alyx-matlab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alyx-matlab b/alyx-matlab index 407b7ff6..8e93baa4 160000 --- a/alyx-matlab +++ b/alyx-matlab @@ -1 +1 @@ -Subproject commit 407b7ff63beba94840354fe16154ee21a6079b61 +Subproject commit 8e93baa4fb29c986985e6320e89d4a94997cc568