-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 597-nwb-to-table-bug
- Loading branch information
Showing
12 changed files
with
705 additions
and
382 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
classdef nwbExportTest < matlab.unittest.TestCase | ||
|
||
properties | ||
NwbObject | ||
OutputFolder = "out" | ||
end | ||
|
||
methods (TestClassSetup) | ||
function setupClass(testCase) | ||
% Get the root path of the matnwb repository | ||
rootPath = misc.getMatnwbDir(); | ||
|
||
% Use a fixture to add the folder to the search path | ||
testCase.applyFixture(matlab.unittest.fixtures.PathFixture(rootPath)); | ||
|
||
% Use a fixture to create a temporary working directory | ||
testCase.applyFixture(matlab.unittest.fixtures.WorkingFolderFixture); | ||
generateCore('savedir', '.'); | ||
end | ||
end | ||
|
||
methods (TestMethodSetup) | ||
function setupMethod(testCase) | ||
testCase.NwbObject = testCase.initNwbFile(); | ||
|
||
if isfolder( testCase.OutputFolder ) | ||
rmdir(testCase.OutputFolder, "s") | ||
end | ||
mkdir(testCase.OutputFolder) | ||
end | ||
end | ||
|
||
methods (Test) | ||
function testExportDependentAttributeWithMissingParentA(testCase) | ||
testCase.NwbObject.general_source_script_file_name = 'my_test_script.m'; | ||
nwbFilePath = fullfile(testCase.OutputFolder, 'test_part1.nwb'); | ||
testCase.verifyWarning(@(f, fn) nwbExport(testCase.NwbObject, nwbFilePath), 'NWB:DependentAttributeNotExported') | ||
|
||
% Add value for dataset which attribute depends on and export again | ||
testCase.NwbObject.general_source_script = 'my test'; | ||
nwbFilePath = fullfile(testCase.OutputFolder, 'test_part2.nwb'); | ||
testCase.verifyWarningFree(@(f, fn) nwbExport(testCase.NwbObject, nwbFilePath)) | ||
end | ||
|
||
function testExportDependentAttributeWithMissingParentB(testCase) | ||
time_series = types.core.TimeSeries( ... | ||
'data', linspace(0, 0.4, 50), ... | ||
'starting_time_rate', 10.0, ... | ||
'description', 'a test series', ... | ||
'data_unit', 'n/a' ... | ||
); | ||
|
||
testCase.NwbObject.acquisition.set('time_series', time_series); | ||
nwbFilePath = fullfile(testCase.OutputFolder, 'test_part1.nwb'); | ||
testCase.verifyWarning(@(f, fn) nwbExport(testCase.NwbObject, nwbFilePath), 'NWB:DependentAttributeNotExported') | ||
|
||
% Add value for dataset which attribute depends on and export again | ||
time_series.starting_time = 1; | ||
nwbFilePath = fullfile(testCase.OutputFolder, 'test_part2.nwb'); | ||
testCase.verifyWarningFree(@(f, fn) nwbExport(testCase.NwbObject, nwbFilePath)) | ||
end | ||
end | ||
|
||
methods (Static) | ||
function nwb = initNwbFile() | ||
nwb = NwbFile( ... | ||
'session_description', 'test file for nwb export', ... | ||
'identifier', 'export_test', ... | ||
'session_start_time', datetime("now", 'TimeZone', 'local') ); | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.