Skip to content
Snippets Groups Projects
Commit 44db5d24 authored by Federico Felici's avatar Federico Felici Committed by Olivier Sauter
Browse files

Add ids tests and cleanup requestnames classes

parent 00cd89d3
No related branches found
No related tags found
1 merge request!4Feature/testsuite
function passed = test_tcv_get_ids
thispath = fileparts(mfilename('fullpath'));
run(fullfile(thispath,'..','gdatpaths'));
% simple test to check functionality
shotlist = [-1,40000];
for ishot=1:numel(shotlist)
shot = shotlist(ishot);
pf_active = tcv2ids(shot,'ids_names',{'pf_active','wall'});
end
passed = true;
end
classdef (SharedTestFixtures={...
check_mds,setup_gdatpaths})...
test_tcv_get_ids < matlab.unittest.TestCase
properties(TestParameter)
shot = {'-1','40000','61400'};
ids_name = {'pf_active','wall'};
end
methods(Test,TestTags = {'IMAS'})
function test_tcv2ids(testCase,shot,ids_name)
ids = tcv2ids(shot,ids_name);
testCase.assertTrue(~isempty(ids))
end
end
end
\ No newline at end of file
......@@ -10,9 +10,11 @@ end
%% populate suite
% add path with tests
addpath(genpath(fullfile(fileparts(mfilename('fullpath')),'tests')));
addpath(genpath(fullfile(fileparts(mfilename('fullpath')),'TCV_IMAS')));
suite_all = [matlab.unittest.TestSuite.fromClass(?test_requestnames_TCV),...
matlab.unittest.TestSuite.fromClass(?test_requestnames_AUG)];
matlab.unittest.TestSuite.fromClass(?test_requestnames_AUG),...
matlab.unittest.TestSuite.fromClass(?test_tcv_get_ids)];
switch test_case
case 'all'
......@@ -20,10 +22,15 @@ switch test_case
case 'basic'
import matlab.unittest.selectors.HasParameter;
import matlab.unittest.selectors.HasName;
import matlab.unittest.selectors.HasTag;
import matlab.unittest.constraints.ContainsSubstring;
suite = suite_all.selectIf(HasParameter('Value','TCV') & ...
(HasParameter('Value','ip') | HasParameter('Value','q_rho')));
s1 = HasName(ContainsSubstring('TCV')) & ...
(HasParameter('Value','ip') | HasParameter('Value','q_rho'));
s2 = HasTag('IMAS');
suite = suite_all.selectIf(s1 | s2);
case 'TCV'
suite = suite_all.selectIf(HasParameter('machine',IsEqualTo('TCV')));
case 'AUG'
......@@ -56,27 +63,3 @@ else
end
end
function [shots,request_list] = get_gdat_test_params(machine)
% get requests for this machine
[gd0,~] = gdat('machine',machine);
request_list = gd0.gdat_request;
% get test shot list for this machine
shots = get_shots(machine);
end
function shots = get_shots(machine)
switch machine
case 'AUG'
shots = {num2str(30594)}; % use strings for display purposes
case 'TCV'
shots = {num2str(48836)};
otherwise
error('no shot defined for this machine')
end
end
classdef (SharedTestFixtures={...
check_mds,setup_gdatpaths}) ...
test_requestnames < matlab.unittest.TestCase
check_mds,setup_gdatpaths}) ...
test_requestnames < matlab.unittest.TestCase
properties(TestParameter,Abstract)
% parameters that will vary during tests
properties (Abstract)
machine;
end
properties(TestParameter,Abstract)
% parameters that will vary during tests
shot;
request; % placeholders
end
methods(Test)
function test_gdat_call(testCase,machine,shot,request)
function test_gdat_call(testCase,shot,request)
testCase.assertTrue(isnumeric(str2double(shot)));
testCase.assertTrue(ischar(request));
machine = testCase.machine;
% gdat call
gdat_call = sprintf(['gdat_' lower(machine) '(%s,''%s'')'],shot,request);
......
classdef test_requestnames_AUG < test_requestnames
% everything implemented in superclass
properties
machine = 'AUG';
end
properties(TestParameter)
% parameters that will vary during tests
machine = {'AUG'};
shot = {'30594'};
request = get_all_gdat_requests('AUG');
end
......
classdef test_requestnames_TCV < test_requestnames
% everything is implemented in superclass!
properties
machine = 'TCV';
end
properties(TestParameter)
% parameters that will vary during tests
machine = {'TCV'};
shot = {'48836'};
request = get_all_gdat_requests('TCV');
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment