From be7d15aa2891d4147b4c9d372e2be5556860779e Mon Sep 17 00:00:00 2001 From: Henry Luetcke <hluetcke@ethz.ch> Date: Wed, 30 Jun 2021 15:01:12 +0200 Subject: [PATCH] work on test function --- obi_test.m | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/obi_test.m b/obi_test.m index c9bf8239e67..b60c1391cf8 100644 --- a/obi_test.m +++ b/obi_test.m @@ -1,9 +1,17 @@ -function pass = obi_test +function pass = obi_test(varargin) %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) pass = true; +if nargin == 1 + teardown = varargin{1}; +else + teardown = true; +end + %% 0. Check if pyversion is setup correctly %% 1. Login to openBIS @@ -22,7 +30,15 @@ spaces = obi.get_spaces(); assert(any(ismember(spaces.code, space_name)), 'Space has not been created'); %% 3. Create project for test - +project_name = 'TESTING_PROJECT'; +try + project = obi.new_project(space, project_name, 'a project for tests of the Matlab openBIS Toolbox'); +catch + disp('Could not create requested project') + rethrow(lasterror) +end +projects = obi.get_projects(space_name, project_name); +assert(any(ismember(projects.identifier, sprintf('/%s/%s', space_name, project_name))), 'Project has not been created'); %% 4. Create experiment for test @@ -34,7 +50,12 @@ assert(any(ismember(spaces.code, space_name)), 'Space has not been created'); %% 7. Tear-down (delete everything, optional) - +if teardown + % delete project + obi.delete_project(project_name, 'created by Matlab-openBIS toolbox test function') + % delete space + obi.delete_space(space, 'created by Matlab-openBIS toolbox test function') +end %% 8. Logout obi.logout() -- GitLab