Skip to content

Commit

Permalink
update webtools tests with new url
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelson-numerical-software committed Oct 25, 2024
1 parent 8fe7645 commit 2b1cfbd
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 12 deletions.
3 changes: 2 additions & 1 deletion modules/webtools/tests/test_websave_1.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
%=============================================================================
url = 'https://apod.nasa.gov/apod/image/2310/MoValleyEclipse.jpg';
filename = [tempdir(), 'MoValleyEclipse_2.jpg'];
options = weboptions('Timeout', 120);
try
destination_filename = websave(filename, url);
destination_filename = websave(filename, url, options);
catch ex
R = strcmp(ex.message, _('Forbidden (403)')) || ...
strcmp(ex.message, _('Timeout was reached')) || ...
Expand Down
1 change: 1 addition & 0 deletions modules/webtools/tests/test_websave_2.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
strcmp(ex.message, _('Couldn''t resolve host name'));
skip_testsuite(R, ex.message)
end
assert_istrue(isfile(destination_filename));
info = dir(destination_filename);
assert_istrue(info.bytes > 1000);
txt = fileread(destination_filename);
Expand Down
22 changes: 14 additions & 8 deletions modules/webtools/tests/test_websave_3.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
% SPDX-License-Identifier: LGPL-3.0-or-later
% LICENCE_BLOCK_END
%=============================================================================
url = 'https://neo.gsfc.nasa.gov/wms/wms';
url = 'https://s.w-x.co/staticmaps/WEB_Current_Weather_Map_1280x720.jpg?crop=16:9&width=800&format=pjpg&auto=webp&quality=60';
filename = [tempdir(), 'earth2.jpg'];
if isfile(filename)
rmfile(filename);
end
testPass = false;
i = 0;
retry = true;
while (retry)
try
destination_filename = websave(filename, url, 'Time', '2019-06-01', 'Service', 'WMS', 'Layers', 'BlueMarbleNG-TB', 'CRS', 'CRS:84', 'Format', 'image/jpeg', 'Height',768, 'Width', 1024,'BBOX','-180.0,-90.0,180.0,90.0','Version','1.3.0','Request','GetMap');
destination_filename = websave(filename, url);
testPass = true;
catch ex
testPass = (strcmp(ex.message, 'Bad Request (400)') == 1);
if ~testPass
Expand All @@ -24,11 +28,13 @@
i = i + 1;
retry = ~testPass && (i < 5);
end

R = strcmp(ex.message, _('Forbidden (403)')) || ...
strcmp(ex.message, _('Timeout was reached')) || ...
strcmp(ex.message, _('Couldn''t resolve host name'));
skip_testsuite(R, ex.message)

if isvar('ex')
R = strcmp(ex.message, _('Forbidden (403)')) || ...
strcmp(ex.message, _('Bad Request (400)')) || ...
strcmp(ex.message, _('Timeout was reached')) || ...
strcmp(ex.message, _('Couldn''t resolve host name'));
skip_testsuite(R, ex.message)
end
assert_istrue(isfile(destination_filename));
assert_istrue(testPass)
%=============================================================================
5 changes: 3 additions & 2 deletions modules/webtools/tests/test_websave_4.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
options = weboptions('Timeout', Inf);
try
destination_filename = websave(filename, url, options);
info = dir(destination_filename);
assert_istrue(info.bytes > 0);
catch ex
R = strcmp(ex.message, _('Forbidden (403)')) || ...
strcmp(ex.message, _('Timeout was reached')) || ...
strcmp(ex.message, _('Couldn''t resolve host name'));
skip_testsuite(R, ex.message)
end
assert_istrue(isfile(destination_filename));
info = dir(destination_filename);
assert_istrue(info.bytes > 0);
%=============================================================================
3 changes: 2 additions & 1 deletion modules/webtools/tests/test_websave_5.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
strcmp(ex.message, _('Couldn''t resolve host name'));
skip_testsuite(R, ex.message)
end
txt = fileread(filename);
assert_istrue(isfile(destination_filename));
txt = fileread(destination_filename);
st = jsondecode(txt);
assert_isequal(st(1).email, '[email protected]');
%=============================================================================
1 change: 1 addition & 0 deletions modules/webtools/tests/test_websave_6.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
strcmp(ex.message, _('Couldn''t resolve host name'));
skip_testsuite(R, ex.message)
end
assert_istrue(isfile(destination_filename));
info = dir(destination_filename);
assert_istrue(info.bytes > 200);
%=============================================================================
1 change: 1 addition & 0 deletions modules/webtools/tests/test_websave_delete.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
strcmp(ex.message, _('Couldn''t resolve host name'));
skip_testsuite(R, ex.message)
end
assert_istrue(isfile(fullname));
R = jsondecode(fileread(fullname));
REF = struct();
assert_isequal(R, REF);
Expand Down
1 change: 1 addition & 0 deletions modules/webtools/tests/test_websave_get_1.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
filename = [tempdir(), 'MoValleyEclipse_1.jpg'];
try
outfilename = websave(filename, url);
assert_istrue(isfile(outfilename));
catch ex
R = strcmp(ex.message, _('Forbidden (403)')) || ...
strcmp(ex.message, _('Timeout was reached')) || ...
Expand Down
1 change: 1 addition & 0 deletions modules/webtools/tests/test_websave_get_2.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
strcmp(ex.message, _('Couldn''t resolve host name'));
skip_testsuite(R, ex.message)
end
assert_istrue(isfile(fullname));
R = jsondecode(fileread(fullname));
assert_isequal(R(5).email, '[email protected]');
%=============================================================================
1 change: 1 addition & 0 deletions modules/webtools/tests/test_websave_get_3.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
strcmp(ex.message, _('Couldn''t resolve host name'));
skip_testsuite(R, ex.message)
end
assert_istrue(isfile(fullname));
R = jsondecode(fileread(fullname));
assert_isequal(R(5).email, '[email protected]');
%=============================================================================
2 changes: 2 additions & 0 deletions modules/webtools/tests/test_websave_patch.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
strcmp(ex.message, _('Couldn''t resolve host name'));
skip_testsuite(R, ex.message)
end
assert_istrue(isfile(fullname));
R = jsondecode(fileread(fullname));
assert_isequal(R.id, 1);
%=============================================================================
Expand All @@ -29,6 +30,7 @@
strcmp(ex.message, _('Couldn''t resolve host name'));
skip_testsuite(R, ex.message)
end
assert_istrue(isfile(fullname));
R = jsondecode(fileread(fullname));
assert_isequal(R.id, 1);
%=============================================================================
1 change: 1 addition & 0 deletions modules/webtools/tests/test_websave_post.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
strcmp(ex.message, _('Couldn''t resolve host name'));
skip_testsuite(R, ex.message)
end
assert_istrue(isfile(fullname));
R = jsondecode(fileread(fullname));
assert_isequal(R.id, 101);
%=============================================================================
1 change: 1 addition & 0 deletions modules/webtools/tests/test_websave_url_1.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
end
end
skip_testsuite(~ok, 'Timeout reached')
assert_istrue(isfile(fullname));
R = jsondecode(fileread(fullname));
assert_istrue(isstruct(R.args));
assert_isequal(fieldnames(R.args), {'b_'; 'r'});
Expand Down
1 change: 1 addition & 0 deletions modules/webtools/tests/test_websave_url_2.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
strcmp(ex.message, _('Couldn''t resolve host name'));
skip_testsuite(R, ex.message)
end
assert_istrue(isfile(fullname));
R = jsondecode(fileread(fullname))
%=============================================================================
1 change: 1 addition & 0 deletions modules/webtools/tests/test_websave_url_3.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
strcmp(ex.message, _('Couldn''t resolve host name'));
skip_testsuite(R, ex.message)
end
assert_istrue(isfile(fullname));
R = jsondecode(fileread(fullname))
%=============================================================================
1 change: 1 addition & 0 deletions modules/webtools/tests/test_websave_url_4.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
strcmp(ex.message, _('Couldn''t resolve host name'));
skip_testsuite(R, ex.message)
end
assert_istrue(isfile(fullname));
R = jsondecode(fileread(fullname))
%=============================================================================
1 change: 1 addition & 0 deletions modules/webtools/tests/test_websave_url_5.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
strcmp(ex.message, _('Couldn''t resolve host name'));
skip_testsuite(R, ex.message)
end
assert_istrue(isfile(fullname));
R = jsondecode(fileread(fullname))
%=============================================================================

0 comments on commit 2b1cfbd

Please sign in to comment.