Commit 76c0cebf authored by Dóra Kocsis's avatar Dóra Kocsis

add test folder

parent 7e85f512
function test_fetch_series_by_api_link()
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(provider_codes{1} == "BIS");
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(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
\ No newline at end of file
function test_fetch_series_by_code()
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(provider_codes{1} == "AMECO");
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(dataset_codes{1} == "ZUTN");
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
assert(length(series_codes) == 1);
assert(series_codes{1} == "EA19.1.0.0.0.ZUTN");
end
\ No newline at end of file
function test_fetch_series_by_code_mask()
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(provider_codes{1} == "IMF");
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(dataset_codes{1} == "CPI");
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
assert(length(series_codes) == 4);
end
\ No newline at end of file
function test_fetch_series_by_code_mask_with_plus_in_dimension_code()
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(provider_codes{1} == "SCB");
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(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
\ No newline at end of file
function test_fetch_series_by_dimension()
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(provider_codes{1} == "WB");
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(dataset_codes{1} == "DB");
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
assert(length(series_codes) == 3);
end
\ No newline at end of file
function test_fetch_series_by_id()
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(provider_codes{1} == "AMECO");
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(dataset_codes{1} == "ZUTN");
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
assert(length(series_codes) == 1);
assert(series_codes{1} == "EA19.1.0.0.0.ZUTN");
end
\ No newline at end of file
function test_fetch_series_by_ids_in_different_datasets()
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(provider_codes{1} == "AMECO");
assert(provider_codes{2} == "BIS");
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 2);
assert(dataset_codes{1} == "ZUTN");
assert(dataset_codes{2} == "cbs");
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
assert(length(series_codes) == 2);
assert(series_codes{1} == "EA19.1.0.0.0.ZUTN");
assert(series_codes{2} == "Q.S.5A.4B.F.B.A.A.LC1.A.1C");
end
\ No newline at end of file
function test_fetch_series_by_ids_in_same_dataset()
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(provider_codes{1} == "AMECO");
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(dataset_codes{1} == "ZUTN");
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
assert(length(series_codes) == 2);
assert(series_codes{1} == "DNK.1.0.0.0.ZUTN");
assert(series_codes{2} == "EA19.1.0.0.0.ZUTN");
end
\ No newline at end of file
function test_fetch_series_of_dataset()
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(provider_codes{1} == "AMECO");
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(dataset_codes{1} == "ZUTN");
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
assert(length(series_codes) > 1);
end
\ No newline at end of file
function test_fetch_series_with_max_nb_series()
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(provider_codes{1} == "AMECO");
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(dataset_codes{1} == "ZUTN");
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
assert(length(series_codes) <= 20);
end
\ No newline at end of file
function test_fetch_series_with_na_values()
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(provider_codes{1} == "AMECO");
idx = find(strcmp('dataset_code',df(1,:)));
dataset_codes = unique(df(2:end,idx));
assert(length(dataset_codes) == 1);
assert(dataset_codes{1} == "ZUTN");
idx = find(strcmp('series_code',df(1,:)));
series_codes = unique(df(2:end,idx));
assert(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
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment