diff --git a/.gitignore b/.gitignore index d30ed2ebc17c0ec0e3c79abaf9d1cca8a2f81fb8..0c80b3c18d020e95e9a9056d5406eb0a2d139741 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e7af8724042429326c2ad3ab13a89d1fd8655c5..681900036811d1fa7690c0b936a061c06e5083a7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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: diff --git a/Makefile b/Makefile index 6c1b562af5be3c36a9cbf57fd29b08463ba612cb..6ab58dae1dfbdb6fc834d1735094808f774fa2b1 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/archive/template.m b/archive/template.m index 183ab9c9ff97a0bc634155b2607f7d5e22b1c47b..99d05398a233a40a978a5f8116759a0f0c5799be 100644 --- a/archive/template.m +++ b/archive/template.m @@ -1,23 +1,45 @@ % 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',... diff --git a/src/subroutines/fetch_series.m b/src/subroutines/fetch_series.m index 2cc9a0348ee6e8aa7587bb4bb2e100a833a6ad09..b437dcfa5c8b01547a696ca644048878ad05e288 100644 --- a/src/subroutines/fetch_series.m +++ b/src/subroutines/fetch_series.m @@ -1,4 +1,4 @@ -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 diff --git a/src/subroutines/fetch_series_by_api_link.m b/src/subroutines/fetch_series_by_api_link.m index 64a98a963ddb7f28ecf7612e0779204e941a6127..dd438fccf450f395a7208e7a0a604c1b32331ce0 100644 --- a/src/subroutines/fetch_series_by_api_link.m +++ b/src/subroutines/fetch_series_by_api_link.m @@ -1,4 +1,4 @@ -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 diff --git a/tests/runalltests.m b/src/subroutines/runalltests.m similarity index 93% rename from tests/runalltests.m rename to src/subroutines/runalltests.m index e0c15a229eda9c529b610b1312760e9876ac9365..b4e639f2ad04809981576856fdf203e562ff0c58 100644 --- a/tests/runalltests.m +++ b/src/subroutines/runalltests.m @@ -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 diff --git a/tests/test_fetch_series_by_api_link.m b/tests/test_fetch_series_by_api_link.m deleted file mode 100644 index 6205d387683d9eb42e0a978dc2202407bd2c3d29..0000000000000000000000000000000000000000 --- a/tests/test_fetch_series_by_api_link.m +++ /dev/null @@ -1,28 +0,0 @@ -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 diff --git a/tests/test_fetch_series_by_code.m b/tests/test_fetch_series_by_code.m deleted file mode 100644 index 4303118e5f77ec8ab956b3fe467f71340ef07c44..0000000000000000000000000000000000000000 --- a/tests/test_fetch_series_by_code.m +++ /dev/null @@ -1,29 +0,0 @@ -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 diff --git a/tests/test_fetch_series_by_code_mask.m b/tests/test_fetch_series_by_code_mask.m deleted file mode 100644 index 6f1d4a6c8e6c2842d80817f465b620b6e24e1aa9..0000000000000000000000000000000000000000 --- a/tests/test_fetch_series_by_code_mask.m +++ /dev/null @@ -1,28 +0,0 @@ -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 diff --git a/tests/test_fetch_series_by_code_mask_with_plus.m b/tests/test_fetch_series_by_code_mask_with_plus.m deleted file mode 100644 index b38bd73d15cadbe884c1d2d5db4faaa1442064fc..0000000000000000000000000000000000000000 --- a/tests/test_fetch_series_by_code_mask_with_plus.m +++ /dev/null @@ -1,30 +0,0 @@ -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 diff --git a/tests/test_fetch_series_by_dimension.m b/tests/test_fetch_series_by_dimension.m deleted file mode 100644 index 35084049b431e8530977acbf6dd4bc79b596842c..0000000000000000000000000000000000000000 --- a/tests/test_fetch_series_by_dimension.m +++ /dev/null @@ -1,28 +0,0 @@ -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 diff --git a/tests/test_fetch_series_by_id.m b/tests/test_fetch_series_by_id.m deleted file mode 100644 index e87b494f67f535da848845c7b3abf11d10b4eb11..0000000000000000000000000000000000000000 --- a/tests/test_fetch_series_by_id.m +++ /dev/null @@ -1,29 +0,0 @@ -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 diff --git a/tests/test_fetch_series_by_ids_in_different_datasets.m b/tests/test_fetch_series_by_ids_in_different_datasets.m deleted file mode 100644 index d71df243ed7bf74c36fc1b9866bedc0c1da1604b..0000000000000000000000000000000000000000 --- a/tests/test_fetch_series_by_ids_in_different_datasets.m +++ /dev/null @@ -1,32 +0,0 @@ -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 diff --git a/tests/test_fetch_series_by_ids_in_same_dataset.m b/tests/test_fetch_series_by_ids_in_same_dataset.m deleted file mode 100644 index c44b6bc3fbed0397bded5d66315f9508de02875c..0000000000000000000000000000000000000000 --- a/tests/test_fetch_series_by_ids_in_same_dataset.m +++ /dev/null @@ -1,31 +0,0 @@ -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 diff --git a/tests/test_fetch_series_of_dataset.m b/tests/test_fetch_series_of_dataset.m deleted file mode 100644 index 0b644a89a9e1cb45d47430fe217ce0280eb1c03f..0000000000000000000000000000000000000000 --- a/tests/test_fetch_series_of_dataset.m +++ /dev/null @@ -1,28 +0,0 @@ -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')); - -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_of_dataset(); -%$ t(1) = true; -%$ catch -%$ t(1) = false; -%$ end -%$ -%$ T = t(1); -%@eof:1 \ No newline at end of file diff --git a/tests/test_fetch_series_with_filter_on_one_series.m b/tests/test_fetch_series_with_filter_on_one_series.m deleted file mode 100644 index 4fb85b51224632a17d4a8bae416f933e11a994e7..0000000000000000000000000000000000000000 --- a/tests/test_fetch_series_with_filter_on_one_series.m +++ /dev/null @@ -1,35 +0,0 @@ -function test_fetch_series_with_filter_on_one_series() % --*-- Unitary tests --*-- -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_); - -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(strcmp(series_codes{1},'DEU.1.0.0.0.ZUTN')); - -assert(any(find(strcmp('filtered',df(1,:))))); -idx_freq = find(strcmp('x_frequency',df(1,:))); -frequencies = unique(df(2:end, idx_freq)); -assert(any(strcmp(frequencies, 'monthly'))); -assert(any(contains(series_codes, '_filtered'))); -end - -%@test:1 -%$ try -%$ test_fetch_series_with_filter_on_one_series(); -%$ t(1) = true; -%$ catch -%$ t(1) = false; -%$ end -%$ -%$ T = t(1); -%@eof:1 \ No newline at end of file diff --git a/tests/test_fetch_series_with_max_nb_series.m b/tests/test_fetch_series_with_max_nb_series.m deleted file mode 100644 index 77b4d7da6b112b1516031026f1429ae61805e446..0000000000000000000000000000000000000000 --- a/tests/test_fetch_series_with_max_nb_series.m +++ /dev/null @@ -1,28 +0,0 @@ -function test_fetch_series_with_max_nb_series() % --*-- Unitary tests --*-- -df = fetch_series('provider_code', 'AMECO', 'dataset_code', 'ZUTN', 'max_nb_series',20); - -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) <= 20); -end - -%@test:1 -%$ try -%$ test_fetch_series_with_max_nb_series(); -%$ t(1) = true; -%$ catch -%$ t(1) = false; -%$ end -%$ -%$ T = t(1); -%@eof:1 \ No newline at end of file diff --git a/tests/test_fetch_series_with_na_values.m b/tests/test_fetch_series_with_na_values.m deleted file mode 100644 index 8dd7ef097003a11e3a7dc0cfae8b99b0483ec67c..0000000000000000000000000000000000000000 --- a/tests/test_fetch_series_with_na_values.m +++ /dev/null @@ -1,34 +0,0 @@ -function test_fetch_series_with_na_values() % --*-- Unitary tests --*-- -df = fetch_series('provider_code', 'AMECO', 'dataset_code', 'ZUTN', 'series_code', 'DEU.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(strcmp(series_codes{1},'DEU.1.0.0.0.ZUTN')); - -idx = find(strcmp('original_value',df(1,:))); -assert(any(strcmp('NA', df(2:end,idx))) == true); - -idx = find(strcmp('value',df(1,:))); -assert(any(isnan(cell2mat(df(2:end,idx)))) == true); -end - -%@test:1 -%$ try -%$ test_fetch_series_with_na_values(); -%$ t(1) = true; -%$ catch -%$ t(1) = false; -%$ end -%$ -%$ T = t(1); -%@eof:1 \ No newline at end of file