Home > api-openbis-matlab > obi_test.m

obi_test

PURPOSE ^

obi_test Testing function for the Matlab openBIS Toolbox

SYNOPSIS ^

function pass = obi_test(varargin)

DESCRIPTION ^

obi_test Testing function for the Matlab openBIS Toolbox
   This function runs a few tests for the Matlab openBIS Toolbox. It
   returns true if all the tests pass successfully and fasle otherwise.
   Input argumtents (all optional):
   teardown ... delete everything at the end (true)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function pass = obi_test(varargin)
0002 %obi_test Testing function for the Matlab openBIS Toolbox
0003 %   This function runs a few tests for the Matlab openBIS Toolbox. It
0004 %   returns true if all the tests pass successfully and fasle otherwise.
0005 %   Input argumtents (all optional):
0006 %   teardown ... delete everything at the end (true)
0007 pass = true;
0008 
0009 if nargin == 1
0010     teardown = varargin{1};
0011 else
0012     teardown = true;
0013 end
0014 
0015 %% 0. Check if pyversion is setup correctly
0016 
0017 %% 1. Login to openBIS
0018 obi = OpenBis();
0019 assert(obi.is_session_active(), 'Session not active');
0020 
0021 %% 2. Create space for test
0022 space_name = 'TESTING_SPACE';
0023 try
0024     space = obi.new_space(space_name, 'a space for tests of the Matlab openBIS Toolbox');
0025 catch
0026     disp('Could not create requested space')
0027     rethrow(lasterror)
0028 end
0029 spaces = obi.get_spaces();
0030 assert(any(ismember(spaces.code, space_name)), 'Space has not been created');
0031 
0032 %% 3. Create project for test
0033 project_name = 'TESTING_PROJECT';
0034 try
0035     project = obi.new_project(space, project_name, 'a project for tests of the Matlab openBIS Toolbox');
0036 catch
0037     disp('Could not create requested project')
0038     rethrow(lasterror)
0039 end
0040 projects = obi.get_projects(space_name, project_name);
0041 assert(any(ismember(projects.identifier, sprintf('/%s/%s', space_name, project_name))), 'Project has not been created');
0042 
0043 %% 4. Create experiment for test
0044 experiment_name = 'TESTING_EXPERIMENT';
0045 
0046 
0047 %% 5. Create dataset with dummy files
0048 
0049 
0050 %% 6. Download the created dataset
0051 
0052 
0053 %% 7. Tear-down (delete everything, optional)
0054 if teardown
0055     % delete project
0056     obi.delete_project(project_name, 'created by Matlab-openBIS toolbox test function')
0057     % delete space
0058     obi.delete_space(space, 'created by Matlab-openBIS toolbox test function')
0059 end
0060 
0061 %% 8. Logout
0062 obi.logout()
0063 
0064 end
0065

Generated on Tue 06-Jul-2021 16:01:18 by m2html © 2005