-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mars server list as config argument (#161)
* stand-alone method for testing * QA * mars server list default to legacy if exists * more flexibility
- Loading branch information
Showing
3 changed files
with
51 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
http://a-test-server.url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,26 @@ | ||
# import pytest | ||
import os | ||
|
||
# from cads_adaptors.adaptors import mars | ||
from cads_adaptors.adaptors import mars | ||
|
||
|
||
# @pytest.mark.parametrize( | ||
# "cmd,error_msg", | ||
# ( | ||
# ("cat r; echo error 1>&2; exit 1", "MARS has crashed."), | ||
# ("cat r; touch data.grib; echo error 1>&2", "MARS returned no data."), | ||
# ), | ||
# ) | ||
# def test_execute_mars_errors(tmp_path, monkeypatch, cmd, error_msg): | ||
# monkeypatch.chdir(tmp_path) # execute_mars generates files in the working dir | ||
# context = mars.Context() | ||
# with pytest.raises(RuntimeError, match=error_msg): | ||
# mars.execute_mars( | ||
# {}, | ||
# context=context, | ||
# mars_cmd=("bash", "-c", cmd), | ||
# ) | ||
def test_get_mars_servers(): | ||
mars_servers = mars.get_mars_server_list( | ||
{"mars_servers": "http://b-test-server.url"} | ||
) | ||
assert len(mars_servers) == 1 | ||
assert mars_servers[0] == "http://b-test-server.url" | ||
|
||
|
||
def test_get_mars_servers_list_file(): | ||
mars_servers = mars.get_mars_server_list( | ||
{"mars_server_list": "tests/data/mars_servers.list"} | ||
) | ||
assert len(mars_servers) == 1 | ||
assert mars_servers[0] == "http://a-test-server.url" | ||
|
||
|
||
def test_get_mars_servers_envvar(): | ||
os.environ["MARS_API_SERVER_LIST"] = "tests/data/mars_servers.list" | ||
mars_servers = mars.get_mars_server_list({}) | ||
assert len(mars_servers) == 1 | ||
assert mars_servers[0] == "http://a-test-server.url" |