Commit 0db04cc8 authored by Dóra Kocsis's avatar Dóra Kocsis

move tests under subroutines, closes #9

parent 14c9e07f
......@@ -11,8 +11,9 @@
\#*\#
*.mat
*.asv
tests/git.info
tests/git.last-commit-hash
src/subroutines/git.info
src/subroutines/git.last-commit-hash
/tests
/missing_dbnomics
/utils
\ No newline at end of file
......@@ -10,13 +10,6 @@ test_matlab:
script:
- make check-matlab
test_old_matlab:
stage: test
variables:
MATLAB: /usr/local/MATLAB/R2009b/bin/matlab
script:
- make check-matlab
test_octave:
stage: test
variables:
......
......@@ -7,11 +7,11 @@ m-unit-tests/src/mtest.m:
git clone https://git.dynare.org/Dynare/m-unit-tests
check-octave: m-unit-tests/src/mtest.m
@cd tests ;\
@cd src/subroutines;\
$(OCTAVE) --no-init-file --silent --no-history --eval "addpath([pwd() '/../m-unit-tests/src']); runalltests" && [ ! -f ./failed ] && [ -f ./pass ]
check-matlab: m-unit-tests/src/mtest.m
@$(MATLAB) -nosplash -nodisplay -r "addpath([pwd '/m-unit-tests/src']); cd tests; runalltests; quit" && [ ! -f ./tests/failed ] && [ -f ./tests/pass ]
@$(MATLAB) -nosplash -nodisplay -r "addpath([pwd '/m-unit-tests/src']); cd src/subroutines; runalltests; quit" && [ ! -f ./tests/failed ] && [ -f ./tests/pass ]
check-clean:
rm -f tests/*_test_*.m tests/*.csv tests/*.xls tests/*.xlsx tests/*.mat tests/failed tests/datafile_for_test
......
% fetch series by provider code and dataset code
df = fetch_series('provider_code', 'AMECO', 'dataset_code', 'UVGD', 'max_nb_series', 500);
ds = to_dseries(df);
% fetch one series by ID
df_id = fetch_series('series_ids','AMECO/ZUTN/EA19.1.0.0.0.ZUTN');
ds_id = to_dseries(df_id);
% fetch multiple series by ID
df_ids = fetch_series('series_ids', {'AMECO/ZUTN/EA19.1.0.0.0.ZUTN', 'AMECO/ZUTN/DNK.1.0.0.0.ZUTN'});
ds_ids = to_dseries(df_ids);
% fetch many series by ID from different datasets
df_ids_sets = fetch_series('series_ids', {'AMECO/ZUTN/EA19.1.0.0.0.ZUTN', 'AMECO/ZUTN/DNK.1.0.0.0.ZUTN', 'IMF/CPI/A.AT.PCPIT_IX'});
% fetch time series by code mask
df_code_mask1 = fetch_series('provider_code', 'IMF', 'dataset_code', 'CPI', 'series_code', 'M.FR+DE.PCPIEC_IX+PCPIA_IX');
ds_code_mask1 = to_dseries(df_code_mask1);
df_code_mask2 = fetch_series('provider_code', 'IMF', 'dataset_code', 'CPI', 'series_code', '.FR.PCPIEC_WT');
ds_code_mask2 = to_dseries(df_code_mask1);
% df_code_mask3 = fetch_series('provider_code', 'IMF', 'dataset_code', 'CPI', 'series_code', 'M..PCPIEC_IX+PCPIA_IX', 'max_nb_series', 400);
% fetch series by dimensions
df_dim = fetch_series('provider_code','AMECO', 'dataset_code', 'ZUTN', 'dimensions', '{"geo":["dnk"]}');
ds_dim = to_dseries(df_dim);
df_dims = fetch_series('provider_code','WB','dataset_code','DB', 'dimensions', '{"country":["ES","FR","IT"],"indicator":["IC.REG.COST.PC.FE.ZS.DRFN"]}');
ds_dims = to_dseries(df_dims);
% fetch series by api link
df_link = fetch_series_by_api_link('https://api.db.nomics.world/v22/series/WB/DB?observations=1&dimensions=%7B%22country%22%3A%5B%22FR%22%2C%22IT%22%2C%22ES%22%5D%2C%22indicator%22%3A%5B%22IC.REG.COST.PC.FE.ZS.DRFN%22%5D%7D');
ds_link = to_dseries(df_link);
% fetch series from the cart
df_cart = fetch_series_by_api_link('https://api.db.nomics.world/v22/series?series_ids=AMECO%2FZUTN%2FEA19.1.0.0.0.ZUTN&observations=1');
ds_cart = to_dseries(df_cart);
%%
% fetch many series by ID from different datasets
df_ids_sets = fetch_series('series_ids', {'AMECO/ZUTN/EA19.1.0.0.0.ZUTN', 'AMECO/ZUTN/DNK.1.0.0.0.ZUTN', 'IMF/CPI/A.AT.PCPIT_IX'});
ds_ids_sets = to_dseries(df_ids_sets);
% fetch multi frequency series
df_multi_freq = fetch_series('series_ids', {'BEA/NIUnderlyingDetail-U001BC/S315-A',...
'BEA/NIUnderlyingDetail-U001BC/S315-Q',...
......
function df = fetch_series(varargin)
function df = fetch_series(varargin) % --*-- Unitary tests --*--
% function fetch_series(varargin)
% Download time series from DBnomics.
% Returns a cell array.
......@@ -119,3 +119,235 @@ end
df = fetch_series_by_api_link(api_link, p.Results.dbnomics_filters, p.Results.max_nb_series, default_editor_base_url);
end
%@test:1 % test_fetch_series_by_code
%$ try
%$ df = fetch_series('provider_code', 'AMECO', 'dataset_code', 'ZUTN', 'series_code', 'EA19.1.0.0.0.ZUTN');
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(length(unique(df(2:end,2))),1);
%$ t(3) = dassert(df(2,2), {'AMECO'});
%$ t(4) = dassert(length(unique(df(2:end,3))),1);
%$ t(5) = dassert(df(2,3), {'ZUTN'});
%$ t(6) = dassert(length(unique(df(2:end,5))),1);
%$ t(7) = dassert(df(2,5), {'EA19.1.0.0.0.ZUTN'});
%$ end
%$
%$ T = all(t);
%@eof:1
%@test:2 % test_fetch_series_by_code_mask
%$ try
%$ df = fetch_series('provider_code', 'IMF', 'dataset_code', 'CPI', 'series_code', 'M.FR+DE.PCPIEC_IX+PCPIA_IX');
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(length(unique(df(2:end,2))),1);
%$ t(3) = dassert(df(2,2), {'IMF'});
%$ t(4) = dassert(length(unique(df(2:end,3))),1);
%$ t(5) = dassert(df(2,3), {'CPI'});
%$ t(6) = dassert(length(unique(df(2:end,5))),4);
%$ end
%$
%$ T = all(t);
%@eof:2
%@test:3 % test_fetch_series_by_code_mask_with_plus
%$ try
%$ df = fetch_series('provider_code', 'SCB', 'dataset_code', 'AKIAM', 'series_code', '"J+K"+"G+H".AM0301C1');
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(length(unique(df(2:end,2))),1);
%$ t(3) = dassert(df(2,2), {'SCB'});
%$ t(4) = dassert(length(unique(df(2:end,3))),1);
%$ t(5) = dassert(df(2,3), {'AKIAM'});
%$ t(6) = dassert(length(unique(df(2:end,5))),2);
%$ end
%$
%$ T = all(t);
%@eof:3
%@test:4 % test_fetch_series_by_dimension
%$ try
%$ df = fetch_series('provider_code','WB','dataset_code','DB', 'dimensions', '{"country":["ES","FR","IT"],"indicator":["IC.REG.COST.PC.FE.ZS.DRFN"]}');
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(length(unique(df(2:end,2))),1);
%$ t(3) = dassert(df(2,2), {'WB'});
%$ t(4) = dassert(length(unique(df(2:end,3))),1);
%$ t(5) = dassert(df(2,3), {'DB'});
%$ t(6) = dassert(length(unique(df(2:end,5))),3);
%$ end
%$
%$ T = all(t);
%@eof:4
%@test:5 % test_fetch_series_by_id
%$ try
%$ df = fetch_series('series_ids','AMECO/ZUTN/EA19.1.0.0.0.ZUTN');
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(length(unique(df(2:end,2))),1);
%$ t(3) = dassert(df(2,2), {'AMECO'});
%$ t(4) = dassert(length(unique(df(2:end,3))),1);
%$ t(5) = dassert(df(2,3), {'ZUTN'});
%$ t(6) = dassert(length(unique(df(2:end,5))),1);
%$ t(7) = dassert(df(2,5), {'EA19.1.0.0.0.ZUTN'});
%$ end
%$
%$ T = all(t);
%@eof:5
%@test:6 % test_fetch_series_by_ids_in_different_datasets
%$ try
%$ df = fetch_series('series_ids', {'AMECO/ZUTN/EA19.1.0.0.0.ZUTN', 'BIS/cbs/Q.S.5A.4B.F.B.A.A.LC1.A.1C'});
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if t(1)
%$ provider_codes = unique(df(2:end,2));
%$ t(2) = dassert(length(provider_codes),2);
%$ t(3) = dassert(provider_codes{1}, 'AMECO');
%$ t(4) = dassert(provider_codes{2}, 'BIS');
%$ dataset_codes = unique(df(2:end,3));
%$ t(5) = dassert(length(dataset_codes),2);
%$ t(6) = dassert(dataset_codes{1}, 'ZUTN');
%$ t(7) = dassert(dataset_codes{2}, 'cbs');
%$ series_codes = unique(df(2:end,5));
%$ t(8) = dassert(length(series_codes),2);
%$ t(9) = dassert(series_codes{1}, 'EA19.1.0.0.0.ZUTN');
%$ t(10) = dassert(series_codes{2}, 'Q.S.5A.4B.F.B.A.A.LC1.A.1C');
%$ end
%$
%$ T = all(t);
%@eof:6
%@test:7 % test_fetch_series_by_ids_in_same_dataset
%$ try
%$ df = fetch_series('series_ids', {'AMECO/ZUTN/EA19.1.0.0.0.ZUTN',...
%$ 'AMECO/ZUTN/DNK.1.0.0.0.ZUTN'});
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(length(unique(df(2:end,2))),1);
%$ t(3) = dassert(df(2,2), {'AMECO'});
%$ t(4) = dassert(length(unique(df(2:end,3))),1);
%$ t(5) = dassert(df(2,3), {'ZUTN'});
%$ series_codes = unique(df(2:end,5));
%$ t(6) = dassert(length(series_codes),2);
%$ t(7) = dassert(series_codes{1}, 'DNK.1.0.0.0.ZUTN');
%$ t(8) = dassert(series_codes{2}, 'EA19.1.0.0.0.ZUTN');
%$ end
%$
%$ T = all(t);
%@eof:7
%@test:8 % test_fetch_series_of_dataset
%$ try
%$ df = fetch_series('provider_code', 'AMECO', 'dataset_code', 'ZUTN');
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(length(unique(df(2:end,2))),1);
%$ t(3) = dassert(df(2,2), {'AMECO'});
%$ t(4) = dassert(length(unique(df(2:end,3))),1);
%$ t(5) = dassert(df(2,3), {'ZUTN'});
%$ t(6) = dassert(length(unique(df(2:end,5))), 49);
%$ end
%$
%$ T = all(t);
%@eof:8
%@test:9 % test_fetch_series_with_filter_on_one_series
%$ try
%$ filters_ = '[{"code": "interpolate", "parameters": {"frequency": "monthly", "method": "spline"}}]';
%$ df = fetch_series('provider_code', 'AMECO', 'dataset_code', 'ZUTN', 'series_code', 'DEU.1.0.0.0.ZUTN', 'dbnomics_filters', filters_);
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(length(unique(df(2:end,2))),1);
%$ t(3) = dassert(df(2,2), {'AMECO'});
%$ t(4) = dassert(length(unique(df(2:end,3))),1);
%$ t(5) = dassert(df(2,3), {'ZUTN'});
%$ series_codes = unique(df(2:end,5));
%$ t(6) = dassert(length(unique(df(2:end,5))),2);
%$ t(7) = dassert(df(2,5), {'DEU.1.0.0.0.ZUTN'});
%$ t(8) = dassert(series_codes{2}, 'DEU.1.0.0.0.ZUTN_filtered');
%$ freq_ = unique(df(2:end, 1));
%$ t(9) = dassert(freq_{2}, 'monthly');
%$ t(10) = dassert(df(1,12), {'filtered'});
%$ end
%$
%$ T = all(t);
%@eof:9
%@test:10 % test_fetch_series_with_max_nb_series
%$ try
%$ df = fetch_series('provider_code', 'AMECO', 'dataset_code', 'ZUTN', 'max_nb_series',20);
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(length(unique(df(2:end,2))),1);
%$ t(3) = dassert(df(2,2), {'AMECO'});
%$ t(4) = dassert(length(unique(df(2:end,3))),1);
%$ t(5) = dassert(df(2,3), {'ZUTN'});
%$ series_codes = unique(df(2:end,5));
%$ assert(length(series_codes) <= 20);
%$ end
%$
%$ T = all(t);
%@eof:10
%@test:11 % test_fetch_series_with_na_values
%$ try
%$ df = fetch_series('provider_code', 'AMECO', 'dataset_code', 'ZUTN', 'series_code', 'DEU.1.0.0.0.ZUTN');
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(length(unique(df(2:end,2))),1);
%$ t(3) = dassert(df(2,2), {'AMECO'});
%$ t(4) = dassert(length(unique(df(2:end,3))),1);
%$ t(5) = dassert(df(2,3), {'ZUTN'});
%$ t(6) = dassert(length(unique(df(2:end,5))),1);
%$ t(7) = dassert(df(2,5), {'DEU.1.0.0.0.ZUTN'});
%$ assert(any(strcmp('NA', df(2:end,9))) == true);
%$ assert(any(isnan(cell2mat(df(2:end,10)))) == true);
%$ end
%$
%$ T = all(t);
%@eof:11
function df = fetch_series_by_api_link(api_link, varargin)
function df = fetch_series_by_api_link(api_link, varargin) % --*-- Unitary tests --*--
% function fetch_series_by_api_link(api_link, varargin)
% Fetch series given an "API link" URL.
% "API link" URLs can be found on DBnomics web site (https://db.nomics.world/) on dataset or series pages using "Download" buttons.
......@@ -168,4 +168,23 @@ else
series_length=series_length+length(flat_series.value);
end
end
end
\ No newline at end of file
end
%@test:1 % test_fetch_series_by_api_link
%$ try
%$ df = fetch_series_by_api_link('https://api.db.nomics.world/v22/series/BIS/long_pp?limit=1000&offset=0&q=&observations=1&align_periods=1&dimensions=%7B%7D');
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(length(unique(df(2:end,2))),1);
%$ t(3) = dassert(df(2,2), {'BIS'});
%$ t(4) = dassert(length(unique(df(2:end,3))),1);
%$ t(5) = dassert(df(2,3), {'long_pp'});
%$ t(6) = dassert(length(unique(df(2:end,5))),23);
%$ end
%$
%$ T = all(t);
%@eof:1
\ No newline at end of file
......@@ -34,7 +34,7 @@ unit_tests_root = strrep(which('runalltests'),'runalltests.m','');
try
initialize_mdbnomics();
catch
addpath([unit_tests_root '../src']);
addpath([unit_tests_root '../']);
initialize_mdbnomics();
end
......
function test_fetch_series_by_api_link() % --*-- Unitary tests --*--
df = fetch_series_by_api_link('https://api.db.nomics.world/v22/series/BIS/long_pp?limit=1000&offset=0&q=&observations=1&align_periods=1&dimensions=%7B%7D');
idx = find(strcmp('provider_code',df(1,:)));
provider_codes = unique(df(2:end,idx));
assert(length(provider_codes)==1);
assert(strcmp(provider_codes{1},'BIS'));
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(strcmp(dataset_codes{1},'long_pp'));
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
assert(length(series_codes) > 1);
end
%@test:1
%$ try
%$ test_fetch_series_by_api_link();
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ T = t(1);
%@eof:1
\ No newline at end of file
function test_fetch_series_by_code() % --*-- Unitary tests --*--
df = fetch_series('provider_code', 'AMECO', 'dataset_code', 'ZUTN', 'series_code', 'EA19.1.0.0.0.ZUTN');
idx = find(strcmp('provider_code',df(1,:)));
provider_codes = unique(df(2:end,idx));
assert(length(provider_codes)==1);
assert(strcmp(provider_codes{1},'AMECO'));
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(strcmp(dataset_codes{1},'ZUTN'));
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
assert(length(series_codes) == 1);
assert(strcmp(series_codes{1},'EA19.1.0.0.0.ZUTN'));
end
%@test:1
%$ try
%$ test_fetch_series_by_code();
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ T = t(1);
%@eof:1
\ No newline at end of file
function test_fetch_series_by_code_mask() % --*-- Unitary tests --*--
df = fetch_series('provider_code', 'IMF', 'dataset_code', 'CPI', 'series_code', 'M.FR+DE.PCPIEC_IX+PCPIA_IX');
idx = find(strcmp('provider_code',df(1,:)));
provider_codes = unique(df(2:end,idx));
assert(length(provider_codes)==1);
assert(strcmp(provider_codes{1},'IMF'));
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(strcmp(dataset_codes{1},'CPI'));
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
assert(length(series_codes) == 4);
end
%@test:1
%$ try
%$ test_fetch_series_by_code_mask();
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ T = t(1);
%@eof:1
\ No newline at end of file
function test_fetch_series_by_code_mask_with_plus() % --*-- Unitary tests --*--
df = fetch_series('provider_code', 'SCB', 'dataset_code', 'AKIAM', 'series_code', '"J+K"+"G+H".AM0301C1');
idx = find(strcmp('provider_code',df(1,:)));
provider_codes = unique(df(2:end,idx));
assert(length(provider_codes)==1);
assert(strcmp(provider_codes{1},'SCB'));
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(strcmp(dataset_codes{1},'AKIAM'));
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
check = {'J+K.AM0301C1', 'G+H.AM0301C1'}';
logA = cell2mat(cellfun(@(c)strcmp(c,series_codes),check,'UniformOutput',false));
assert(sum(logA)==2);
end
%@test:1
%$ try
%$ test_fetch_series_by_code_mask_with_plus();
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ T = t(1);
%@eof:1
function test_fetch_series_by_dimension() % --*-- Unitary tests --*--
df = fetch_series('provider_code','WB','dataset_code','DB', 'dimensions', '{"country":["ES","FR","IT"],"indicator":["IC.REG.COST.PC.FE.ZS.DRFN"]}');
idx = find(strcmp('provider_code',df(1,:)));
provider_codes = unique(df(2:end,idx));
assert(length(provider_codes)==1);
assert(strcmp(provider_codes{1},'WB'));
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(strcmp(dataset_codes{1},'DB'));
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
assert(length(series_codes) == 3);
end
%@test:1
%$ try
%$ test_fetch_series_by_dimension();
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ T = t(1);
%@eof:1
\ No newline at end of file
function test_fetch_series_by_id() % --*-- Unitary tests --*--
df = fetch_series('series_ids','AMECO/ZUTN/EA19.1.0.0.0.ZUTN');
idx = find(strcmp('provider_code',df(1,:)));
provider_codes = unique(df(2:end,idx));
assert(length(provider_codes)==1);
assert(strcmp(provider_codes{1},'AMECO'));
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(strcmp(dataset_codes{1},'ZUTN'));
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
assert(length(series_codes) == 1);
assert(strcmp(series_codes{1},'EA19.1.0.0.0.ZUTN'));
end
%@test:1
%$ try
%$ test_fetch_series_by_id();
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ T = t(1);
%@eof:1
\ No newline at end of file
function test_fetch_series_by_ids_in_different_datasets() % --*-- Unitary tests --*--
df = fetch_series('series_ids', {'AMECO/ZUTN/EA19.1.0.0.0.ZUTN', 'BIS/cbs/Q.S.5A.4B.F.B.A.A.LC1.A.1C'});
idx = find(strcmp('provider_code',df(1,:)));
provider_codes = unique(df(2:end,idx));
assert(length(provider_codes)==2);
assert(strcmp(provider_codes{1},'AMECO'));
assert(strcmp(provider_codes{2},'BIS'));
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 2);
assert(strcmp(dataset_codes{1},'ZUTN'));
assert(strcmp(dataset_codes{2},'cbs'));
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
assert(length(series_codes) == 2);
assert(strcmp(series_codes{1},'EA19.1.0.0.0.ZUTN'));
assert(strcmp(series_codes{2},'Q.S.5A.4B.F.B.A.A.LC1.A.1C'));
end
%@test:1
%$ try
%$ test_fetch_series_by_ids_in_different_datasets();
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ T = t(1);
%@eof:1
\ No newline at end of file
function test_fetch_series_by_ids_in_same_dataset() % --*-- Unitary tests --*--
df = fetch_series('series_ids', {'AMECO/ZUTN/EA19.1.0.0.0.ZUTN',...
'AMECO/ZUTN/DNK.1.0.0.0.ZUTN'});
idx = find(strcmp('provider_code',df(1,:)));
provider_codes = unique(df(2:end,idx));
assert(length(provider_codes)==1);
assert(strcmp(provider_codes{1},'AMECO'));
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(strcmp(dataset_codes{1},'ZUTN'));
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
assert(length(series_codes) == 2);
assert(strcmp(series_codes{1},'DNK.1.0.0.0.ZUTN'));
assert(strcmp(series_codes{2},'EA19.1.0.0.0.ZUTN'));
end
%@test:1
%$ try
%$ test_fetch_series_by_ids_in_same_dataset();
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ T = t(1);
%@eof:1
\ No newline at end of file
function test_fetch_series_of_dataset() % --*-- Unitary tests --*--
df = fetch_series('provider_code', 'AMECO', 'dataset_code', 'ZUTN');
idx = find(strcmp('provider_code',df(1,:)));
provider_codes = unique(df(2:end,idx));
assert(length(provider_codes)==1);
assert(strcmp(provider_codes{1},'AMECO'));
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(strcmp(dataset_codes{1},'ZUTN'));