File: test_fdb_tool_request.py

package info (click to toggle)
fdb 5.20.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 89,268 kB
  • sloc: cpp: 40,830; python: 5,079; sh: 4,996; makefile: 32; ansic: 8
file content (32 lines) | stat: -rw-r--r-- 902 bytes parent folder | download | duplicates (2)
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