1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
import datetime
import pytest
from pyfdb._internal.pyfdb_internal import FDBToolRequest
def test_from_internal_selection():
today_date = datetime.date.today()
yesterday = int((today_date - datetime.timedelta(days=1)).strftime("%Y%m%d"))
fdb_tool_request = FDBToolRequest.from_internal_mars_selection({"date": ["-1"]})
print(fdb_tool_request)
str_repr = str(fdb_tool_request)
assert "retrieve" in str_repr
assert f"date={yesterday}" in str_repr
def test_from_selection():
# Internal representation is not respected
with pytest.raises(ValueError, match="Expecting collection of values"):
_ = FDBToolRequest.from_internal_mars_selection({"date": "-1"})
def test_from_selection_all():
fdb_tool_request = FDBToolRequest.from_internal_mars_selection({})
print(fdb_tool_request)
str_repr = str(fdb_tool_request)
assert "ALL" in str_repr
|