-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathtest_latest.py
73 lines (56 loc) · 1.48 KB
/
test_latest.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import datetime
from freezegun import freeze_time
from ecmwf.opendata import Client
TEST_URL = "https://get.ecmwf.int/repository/ecmwf-opendata/testing"
@freeze_time("2022-01-21t13:21:34Z")
def test_utc():
assert datetime.datetime.utcnow() == datetime.datetime(2022, 1, 21, 13, 21, 34)
@freeze_time("2022-01-21T13:21:34Z")
def test_latest_00():
client = Client(TEST_URL)
date = client.latest(
time=0,
step=48,
stream="oper",
type="fc",
levtype="sfc",
param="2t",
target="data.grib",
)
assert date == datetime.datetime(2022, 1, 20)
@freeze_time("2022-01-21T13:21:34Z")
def test_latest_06():
client = Client(TEST_URL)
date = client.latest(
time=6,
step=48,
type="fc",
levtype="sfc",
param="2t",
target="data.grib",
)
assert date == datetime.datetime(2022, 1, 20, 6)
@freeze_time("2022-01-21T13:21:34Z")
def test_latest_12():
client = Client(TEST_URL)
date = client.latest(
time=12,
step=48,
type="fc",
levtype="sfc",
param="2t",
target="data.grib",
)
assert date == datetime.datetime(2022, 1, 20, 12)
@freeze_time("2022-01-20T13:21:34Z")
def test_latest_18():
client = Client(TEST_URL)
date = client.latest(
time=18,
step=48,
type="fc",
levtype="sfc",
param="2t",
target="data.grib",
)
assert date == datetime.datetime(2022, 1, 19, 18)