• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dbekaert / RAiDER / 0725c2a2-51e5-496c-899c-9636990c6d4b

16 Jun 2025 06:33PM UTC coverage: 94.207% (-0.2%) from 94.436%
0725c2a2-51e5-496c-899c-9636990c6d4b

push

circleci

web-flow
Merge pull request #728 from garlic-os/more-downloader-tests

Add downloader tests for HRES, GMAO, MERRA2

10 of 19 new or added lines in 1 file covered. (52.63%)

3269 of 3470 relevant lines covered (94.21%)

0.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.38
/test/test_downloaders.py
1
import datetime as dt
1✔
2
import logging
1✔
3

4
import numpy as np
1✔
5
import pytest
1✔
6
from requests.exceptions import HTTPError
1✔
7

8
from RAiDER.models.era5 import ERA5
1✔
9
from RAiDER.models.era5t import ERA5T
1✔
10
from RAiDER.models.erai import ERAI
1✔
11
from RAiDER.models.gmao import GMAO
1✔
12
from RAiDER.models.hres import HRES
1✔
13
from RAiDER.models.merra2 import MERRA2
1✔
14
from test import TEST_DIR, random_string
1✔
15

16

17
@pytest.mark.long
1✔
18
def test_era5() -> None:
1✔
19
    wm = ERA5()
×
20
    wm.set_latlon_bounds(np.array([10, 10.2, -72, -72]))
×
21
    wm.fetch(
×
22
        TEST_DIR / 'test_geom/test_era5.nc',
23
        dt.datetime(2020, 1, 1, 0, 0, 0).replace(tzinfo=dt.timezone(offset=dt.timedelta())),
24
    )
25

26

27
@pytest.mark.long
1✔
28
def test_era5t() -> None:
1✔
29
    wm = ERA5T()
×
30
    wm.set_latlon_bounds(np.array([10, 10.2, -72, -72]))
×
31
    wm.fetch(
×
32
        TEST_DIR / 'test_geom/test_era5t.nc',
33
        dt.datetime(2020, 1, 1, 0, 0, 0).replace(tzinfo=dt.timezone(offset=dt.timedelta())),
34
    )
35

36

37
@pytest.mark.long
1✔
38
def test_erai() -> None:
1✔
39
    wm = ERAI()
×
40
    wm.set_latlon_bounds(np.array([10, 10.2, -72, -72]))
×
41
    wm.fetch(
×
42
        TEST_DIR / 'test_geom/test_erai.nc',
43
        dt.datetime(2017, 1, 1, 0, 0, 0).replace(tzinfo=dt.timezone(offset=dt.timedelta()))
44
    )
45

46
@pytest.mark.skip  # Paid access
1✔
47
@pytest.mark.long
1✔
48
def test_hres() -> None:
1✔
NEW
49
    wm = HRES()
×
NEW
50
    wm.set_latlon_bounds(np.array([10, 10.2, -72, -72]))
×
NEW
51
    wm.fetch(
×
52
        TEST_DIR / 'test_geom/test_hres.nc',
53
        dt.datetime(2020, 1, 1, 0, 0, 0).replace(tzinfo=dt.timezone(offset=dt.timedelta())),
54
    )
55

56

57
@pytest.mark.long
1✔
58
def test_gmao() -> None:
1✔
NEW
59
    wm = GMAO()
×
NEW
60
    wm.set_latlon_bounds(np.array([10, 10.2, -72, -72]))
×
NEW
61
    wm.fetch(
×
62
        TEST_DIR / 'test_geom/test_gmao.nc',
63
        dt.datetime(2020, 1, 1, 0, 0, 0).replace(tzinfo=dt.timezone(offset=dt.timedelta())),
64
    )
65

66

67
@pytest.mark.long
1✔
68
def test_merra2() -> None:
1✔
NEW
69
    wm = MERRA2()
×
NEW
70
    wm.set_latlon_bounds(np.array([10, 10.2, -72, -72]))
×
NEW
71
    wm.fetch(
×
72
        TEST_DIR / 'test_geom/test_merra2.nc',
73
        dt.datetime(2020, 1, 1, 0, 0, 0).replace(tzinfo=dt.timezone(offset=dt.timedelta())),
74
    )
75

76

77
def test_old_api_url_warning(caplog: pytest.LogCaptureFixture, monkeypatch: pytest.MonkeyPatch) -> None:
1✔
78
    with monkeypatch.context() as mp:
1✔
79
        mp.setenv('CDSAPI_URL', 'https://cds.climate.copernicus.eu/api/v2')
1✔
80
        mp.setenv('CDSAPI_KEY', random_string())
1✔
81
        wm = ERA5()
1✔
82
        wm.set_latlon_bounds(np.array([10, 10.2, -72, -72]))
1✔
83
        with caplog.at_level(logging.WARNING), pytest.raises(HTTPError, match="404"):
1✔
84
            wm.fetch(
1✔
85
                TEST_DIR / 'test_geom/test_era5.nc',
86
                dt.datetime(2020, 1, 1, 0, 0, 0).replace(tzinfo=dt.timezone(offset=dt.timedelta())),
87
            )
88
    assert 'Old CDS API configuration detected' in caplog.text
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc